csv export

 

This mql4 script is not exporting to csv when attached to a chart. Why?

static datetime check;

void start() { if (check!=Time[0]) { check=Time[0]; Write(); } }

//+------------------------------------------------------------------+ 
/| Write | //+------------------------------------------------------------------+ 
void Write() { 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); }

} //+------------------------------------------------------------------+

 

Maybe your handle is not > 0, why don't you heck and report an error to the log if it isn't ?