I am attempting to write to a file and for some reason the file is never created. I even tried making the file manually, but no information is added. I used the exact code that I found on this forum:
//+------------------------------------------------------------------+//| expert initialization function |//+------------------------------------------------------------------+int handle;
datetime MyTime0;
int init()
{
MyTime0=Time[0];
Alert(TimeToStr( TimeCurrent(), TIME_DATE | TIME_SECONDS ));
//Open file/////////////////////////////////////////////////////////////////////////////////////////////////////////
handle=FileOpen("data1.csv",FILE_CSV|FILE_READ|FILE_WRITE,',');
if(handle<1)
{
Comment("File data1.csv not found, the last error is ", GetLastError());
return(false);
}
else
{
Comment("Ok");
FileWrite(handle, "Time","Open","High","Low","Close");
Comment("1");
}
return(handle);
}
//+------------------------------------------------------------------+//| expert deinitialization function |//+------------------------------------------------------------------+int deinit(bool handle)
{
//Close file////////////////////////////////////////////////////////////////////////////////////////////////////FileClose(handle);
return(0);
}
//+------------------------------------------------------------------+//| expert start function |//+------------------------------------------------------------------+int start()
{
int i;
//Write to file//////////////////////////////////////////////////////////////////////////////////////////////if (Time[0]>MyTime0)
{Alert("New bar time ",TimeToStr( Time[0], TIME_DATE | TIME_SECONDS ),
" Completed bar time: ",TimeToStr( Time[1], TIME_DATE | TIME_SECONDS ),
" Saved time: ",TimeToStr( MyTime0, TIME_DATE | TIME_SECONDS ));
FileWrite(handle, TimeToStr( Time[1], TIME_DATE | TIME_SECONDS ), Open[1], High[1], Low[1], Close[1]);
FileFlush(handle);
MyTime0=Time[0];
}
//FileWrite(handle, TimeToStr( TimeCurrent(), TIME_DATE | TIME_SECONDS ), Bid, Ask);return(0);
}
//+------------------------------------------------------------------+
Hi,
I am attempting to write to a file and for some reason the file is never created. I even tried making the file manually, but no information is added. I used the exact code that I found on this forum:
The only error I get is
What could be the cause of this?