Economic Calendar no values

 

Hello there, I am trying to work with the economic calendar, but even a simple query does not bring values.

I am sure I am overlooking some basic thing?


here my program for reference:

MqlCalendarValue values[]; 

datetime date_from = D'28.10.2024';  // take all events from 28. Oct 2024
datetime date_to   = D'30.10.2024';                // 0 means all known events, including the ones that have not occurred yet 


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
    ArraySetAsSeries(values, true);
    ArrayResize(values, 10000);
    return(INIT_SUCCEEDED);
  } // end of init
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)  {  } // end de-init
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick() {

CalendarValueHistory(values, date_from, date_to, NULL, NULL);

if(values[0].actual_value >0) {
   Comment("hold on");
   } // end if
   
  } // end of on Tick
//+------------------------------------------------------------------+
 
Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 

Hello, I found good support in a video here, at least I could manage to download something:

(in French, but you can activate automatic English subtitles), that explains how to access calendar during backtests.

- YouTube
  • www.youtube.com
Enjoy the videos and music that you love, upload original content and share it all with friends, family and the world on YouTube.
 
as I hear in another video, apparently you don't have access to the economic calendar during backtest - don't ask my why, but just to save time in case you are looking for this question
 

Hi

The actual_value might not be set for the event and it will return "LONG_MIN (-9223372036854775808) so your Comment won’t be displayed. Check other values  like event_id or time and you will see that all events are properly obtained by the function. 

Also check other elements of the array other may have set actual_value and you will get proper results. 

Have a nice day👍📊