I have an EA that I'm working on that writes data to a .csv file (one row of data for each day of backtest). It works fine except for a big gap between 10-1-2012 to 12-26-2012 where no data is written to the file. The backtest is for almost an entire year till now. I have tried deleting the history and re-downloading the chart data with the same result. The history data looks fine. When run on a second MT4, it works better, but still has some days missing. It concerns me because I'm not sure if it is a bug in my programming or MT4 or something else. Any advice or suggestions would be appreciated.
void DoDailyProfitWrite()
{
int handle;
if( CurrDay == DayOfWeek()) return;
if(DeleteDailyFile == 0) {FileDelete("Daily" + EA_Comment + Sym + ".csv"); DeleteDailyFile = 1;}string FileDate = TimeToStr(TimeCurrent(),TIME_DATE);
if (DayOfWeek()== 1 || DayOfWeek()== 2 || DayOfWeek()== 3 || DayOfWeek()== 4 && Hour()== 23 && Minute()== 59 && Seconds() >= 29 )
//Seconds greater than 30 or 40 seem to miss some days in the spreadsheet
{
handle=FileOpen("Daily" + EA_Comment + Sym + Period() + WriteFileComment + ".csv", FILE_CSV|FILE_READ|FILE_WRITE, ',');//use comma for excel
if(handle>0)
{
FileSeek(handle, 0, SEEK_END);
//---- add data to the end of file
FileWrite(handle, DayOfWeek(), FileDate, GetProfitToday(), GetOrdersToday() );
FileClose(handle);
handle=0;
CurrDay = DayOfWeek();
}
}//end Monday thru thursday
if(DayOfWeek() == 5 && Hour() == 19 && Minute() == 59 && Seconds() >= 29 ) //Friday write
//Seconds greater than 30 or 40 seem to miss some days in the spreadsheet
{
handle=FileOpen("Daily" + EA_Comment + Sym + Period() + WriteFileComment + ".csv", FILE_CSV|FILE_READ|FILE_WRITE, ',');//use comma for excel
if(handle>0)
{
FileSeek(handle, 0, SEEK_END);
//---- add data to the end of file
FileWrite(handle, DayOfWeek(), FileDate, GetProfitToday(), GetOrdersToday() );
FileClose(handle);
handle=0;
CurrDay = DayOfWeek();
}
}//end Friday
return(0);
}//DoDailyProfitWrite
void DoDailyProfitWrite()
{
int handle;
if( CurrDay == DayOfWeek()) return;
if(DeleteDailyFile == 0) {FileDelete("Daily" + EA_Comment + Sym + ".csv"); DeleteDailyFile = 1;}string FileDate = TimeToStr(TimeCurrent(),TIME_DATE);
if (DayOfWeek()== 1 || DayOfWeek()== 2 || DayOfWeek()== 3 || DayOfWeek()== 4 && Hour()== 23 && Minute()== 59 && Seconds() >= 29 )
//Seconds greater than 30 or 40 seem to miss some days in the spreadsheet
{
handle=FileOpen("Daily" + EA_Comment + Sym + Period() + WriteFileComment + ".csv", FILE_CSV|FILE_READ|FILE_WRITE, ',');//use comma for excel
if(handle>0)
{
FileSeek(handle, 0, SEEK_END);
//---- add data to the end of file
FileWrite(handle, DayOfWeek(), FileDate, GetProfitToday(), GetOrdersToday() );
FileClose(handle);
handle=0;
CurrDay = DayOfWeek();
}
}//end Monday thru thursday
if(DayOfWeek() == 5 && Hour() == 19 && Minute() == 59 && Seconds() >= 29 ) //Friday write
//Seconds greater than 30 or 40 seem to miss some days in the spreadsheet
{
handle=FileOpen("Daily" + EA_Comment + Sym + Period() + WriteFileComment + ".csv", FILE_CSV|FILE_READ|FILE_WRITE, ',');//use comma for excel
if(handle>0)
{
FileSeek(handle, 0, SEEK_END);
//---- add data to the end of file
FileWrite(handle, DayOfWeek(), FileDate, GetProfitToday(), GetOrdersToday() );
FileClose(handle);
handle=0;
CurrDay = DayOfWeek();
}
}//end Friday
return(0);
}//DoDailyProfitWrite