Unable to get Calendar(CalendarValueHistory ) even in back-testing

 

Dear Team,


I have wrote one Algo module to trade automatically based on the news events(https://www.mql5.com/en/economic-calendar),  but if I use the  CalendarValueHistory function in back-testing I am getting 4014 error.  

in back-testing, I am trying to fetch older date news even. for that I am getting 4014 error. please find the code below.

convertedTime  = Older date assigned. e.g: 01-Jan-2023

convertedTime2  = Older date assigned. e.g: 01-Jan-2023

events_count=CalendarValueHistory(values,convertedTime ,convertedTime2,NULL,"USD")


kindly do the needful. thanks. 

Economic Calendar – forex calendar with real-time forex news and reports, schedule of forthcoming world economy events
Economic Calendar – forex calendar with real-time forex news and reports, schedule of forthcoming world economy events
  • www.mql5.com
Economic Calendar – forex calendar with real-time forex news and reports, schedule of forthcoming world economy events. Economic calendar includes most important economic indicators and events from ministries and agencies of different countries. The Calendar is useful for traders in the forex market, stock exchanges and other financial markets.
 
Bharathi M:

Dear Team,


I have wrote one Algo module to trade automatically based on the news events(https://www.mql5.com/en/economic-calendar),  but if I use the  CalendarValueHistory function in back-testing I am getting 4014 error.  

in back-testing, I am trying to fetch older date news even. for that I am getting 4014 error. please find the code below.

convertedTime  = Older date assigned. e.g: 01-Jan-2023

convertedTime2  = Older date assigned. e.g: 01-Jan-2023

events_count=CalendarValueHistory(values,convertedTime ,convertedTime2,NULL,"USD")


kindly do the needful. thanks. 

Calendar data is not available in Backtest. Only live you can request data. The reason is simple. There is no GMT Offset available in Backtesting.

It's a time problem. Time in backtest is all flat to GMT, you do not have valid times available. But news events are synced to your brokers time and chart, this is missing in Backtesting, therefore you cannot sync the events to the correct timing automatically. And since calendar is already corrected to chart time, there will be an offset to the times in Backtest.

Only solution is to create or use a different news database or source. And you will need to implement some time sync function and input to correct the misalignment of event times to chart time.
 

Thank you so much for neat explanation. 

Dominik Christian Egert
Dominik Christian Egert
  • 2022.03.20
  • www.mql5.com
Trader's profile
 
Bharathi M #:

Thank you so much for neat explanation. 

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

 
Bharathi M:

Dear Team,


I have wrote one Algo module to trade automatically based on the news events(https://www.mql5.com/en/economic-calendar),  but if I use the  CalendarValueHistory function in back-testing I am getting 4014 error.  

in back-testing, I am trying to fetch older date news even. for that I am getting 4014 error. please find the code below.

convertedTime  = Older date assigned. e.g: 01-Jan-2023

convertedTime2  = Older date assigned. e.g: 01-Jan-2023

events_count=CalendarValueHistory(values,convertedTime ,convertedTime2,NULL,"USD")


kindly do the needful. thanks. 

https://www.mql5.com/en/forum/326554

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