此脚本在附加到图表时
mql4
不会导出到-file。为什么?CSV
static datetime check;
//+------------------------------------------------------------------+
//| scripts/Export.mq4 pre Build 562- |
//| MQL4/Scripts/Export.mq4 post Build 562+ |
//+------------------------------------------------------------------+
void start() { // New-MQL4 post Build 562+: void OnStart(){}
if ( check != Time[0] ) {
check = Time[0];
WriteCSV();
}
}
//+------------------------------------------------------------------+
//| WriteCSV |
//+------------------------------------------------------------------+
void WriteCSV() {
int handle = FileOpen( StringConcatenate( Symbol(), ".csv" ),
FILE_CSV|FILE_READ|FILE_WRITE, ','
);
if ( handle > 0 ) {
FileSeek( handle, 0, SEEK_END );
FileWrite( handle,
TimeToStr( TimeCurrent(), TIME_DATE ),
iOpen ( Symbol(), Period(), 1 ),
iHigh ( Symbol(), Period(), 1 ),
iLow ( Symbol(), Period(), 1 ),
iClose( Symbol(), Period(), 1 )
);
FileClose( handle );
}
}
//+------------------------------------------------------------------+