Calendar Economic Functions

 

Do the Calendar Economic Functions in MQ5 work during testing or optimization? It seems it doesn't, but I wonder if I am doing using them incorrectly.

this is the code that works find in live trading, but always returns false during testing/optimization.

MqlCalendarValue valuesC1[], valuesC2[];

   datetime dayStartTime=iTime(symbolName,PERIOD_D1,0);
   datetime dayEndTime=dayStartTime+86400;

// search for values in both currencies separately, to have smaller arrays
   CalendarValueHistory(valuesC1,dayStartTime,dayEndTime,NULL,currency1);
   CalendarValueHistory(valuesC2,dayStartTime,dayEndTime,NULL,currency2);

   if(ArraySize(valuesC1)==0 && ArraySize(valuesC2)==0 )return false;
 
better.trader every.day:

Do the Calendar Economic Functions in MQ5 work during testing or optimization? It seems it doesn't, but I wonder if I am doing using them incorrectly.

this is the code that works find in live trading, but always returns false during testing/optimization.

The calendar does not work in the tester off the shelf. You need to make some work to export/import the records into the tester. You can find an example of such implementation in the algotrading book.

MQL5 Book: Advanced language tools / Economic calendar / Transferring calendar database to tester
MQL5 Book: Advanced language tools / Economic calendar / Transferring calendar database to tester
  • www.mql5.com
The calendar is available for MQL programs only online, and therefore testing news trading strategies poses some difficulties. One of the solutions...
 
Thank you. I will take a look at the book.