Does the economy calendar fail in the debugger?

 

Running the attached (and other) EA(s) in the debugger fails to load the Calendar - or am I missing something?

This call:

   if (CalendarValueHistory(evCurr1,tC-(FXOneWeek+FXOneWeek),tC+FXOneWeek,NULL,Curr1)) { // causes err 4014 = ERR_FUNCTION_NOT_ALLOWED: Function is not allowed for call or URL not entered in Optptio=>Expert=>WebRequest URL
      Print(" OK?? m Test_Cal ",__LINE__,"  Calendar: ",Curr1,"  ArrSz: ",ArraySize(evCurr1),"  err: ",_LastError);// BoW(tC)+FXOneWeek,
      ArrayResize(evCurr1,5); 
      ArrayPrint(evCurr1);
  }

returns true(???) but the array is empty and the error is set to 4014 = ERR_FUNCTION_NOT_ALLOWED.

The documentation does not say anything about it (debugger & 4014) and the listed errors are only:

CalendarValueHistory
  • 4001 – ERR_INTERNAL_ERROR  (general runtime error),
  • 4004 – ERR_NOT_ENOUGH_MEMORY (not enough memory for executing a request),
  • 5401 – ERR_CALENDAR_TIMEOUT (request time limit exceeded),
  • 5400 – ERR_CALENDAR_MORE_DATA

I even allowed (just in case) the url: https://www.mql5.com

Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 2023.03.22
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
Files:
 
Carl Schreiber:

Running the attached (and other) EA(s) in the debugger fails to load the Calendar - or am I missing something?

This call:

returns true(???) but the array is empty and the error is set to 4014 = ERR_FUNCTION_NOT_ALLOWED.

The documentation does not say anything about it (debugger & 4014) and the listed errors are only:

I even allowed (just in case) the url: https://www.mql5.com

If the function returns true there is no point to check _LastError which could be set to an unrelated number.

Please post that compiles if you want some to reproduce the issue and help.

 
Alain Verleyen #:

If the function returns true there is no point to check _LastError which could be set to an unrelated number.

Please post that compiles if you want some to reproduce the issue and help.

Hmm?? It runs in the debugger so it compiles without error.

Here the moment before CalendarValueHistory() is called:

_LastError = 0 and everything is set correctly.

An now the moment right after this call:


CalendarValueHistor() has returned true, _LastError has been set to 4014, and Print() will be processed right away, this is printed in the log of the debugger:

2023.03.23 07:07:51.527 2023.01.06 00:00:31    OK?? m Test_Cal 47  Calendar: EUR  ArrSz: 0  err: 4014

  Anyway here is the files I just run

Files:
 
Carl Schreiber #:

Hmm?? It runs in the debugger so it compiles without error.

Here the moment before CalendarValueHistory() is called:

_LastError = 0 and everything is set correctly.

An now the moment right after this call:


CalendarValueHistor() has returned true, _LastError has been set to 4014, and Print() will be processed right away, this is printed in the log of the debugger:

  Anyway here is the files I just run

You run it on the Strategy Tester ? It effectively doesn't work with the Strategy Tester.

There is actually also an error in the documentation, the function returns an int, not a bool. So in your case it returns -1 which effectively means an error 4014.

On a live chart:

2023.03.23 09:08:09.396    test_Calendar__1 (GBPJPY,H1)     OK?? m Test_Cal 47  Calendar: GBP  ArrSz: 55  err: 0

The documentation should be updated and include these information.

 
See here.
MQL5 Economic Calendar / CalendarValueHistory in backtest - How to access the built-in economic calendar during backtest
MQL5 Economic Calendar / CalendarValueHistory in backtest - How to access the built-in economic calendar during backtest
  • 2019.11.15
  • www.mql5.com
Hi all, is there any way to access the built-in economic calendar during backtest. Honestly, it's far from any code that i'm proud of, i did very little in the field of news trading over the past months and in retrospect i would do it in a better organized way
Reason: