Are you sure? Did you search before posting?
It seems that it does work in the Strategy Tester ...
- 2019.11.15
- www.mql5.com
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
- www.mql5.com
Thanks Fernando,
If you read that post, what they claim is that one has to do an alternative code/trick for the use of the calendar data in the backtestings.
Basically, download the news data, save it in a file, and then load it in your EA for backstesting.
It seems weird to me why for backstesting, MQL5 would not allow an EA to read news data directly from the calendar, when the data is already available.
I have found in the Freelancer version of this webpage, that given this limitation many people have opted to create double versions of their EAs. For instance, i noted several requests to create double EAs, one working for the backtesting and other for the real ticks. Others have opted to have both functions optional in the same EA.
My thought is that may be what is happening is that the news calendar could be used in the backtesting directly into an EA, as it would do in real time, but only during the periods for which they have data. But not certain.
I would like to code a news filter, and wanted to know if one really has to code this functionality independently for the historical and real time versions of the EA.
Thanks Fernando,
If you read that post, what they claim is that one has to do an alternative code/trick for the use of the calendar data in the backtestings.
Basically, download the news data, save it in a file, and then load it in your EA for backstesting.
It seems weird to me why for backstesting, MQL5 would not allow an EA to read news data directly from the calendar, when the data is already available.
I have found in the Freelancer version of this webpage, that given this limitation many people have opted to create double versions of their EAs. For instance, i noted several requests to create double EAs, one working for the backtesting and other for the real ticks. Others have opted to have both functions optional in the same EA.
My thought is that may be what is happening is that the news calendar could be used in the backtesting directly into an EA, as it would do in real time, but only during the periods for which they have data. But not certain.
I would like to code a news filter, and wanted to know if one really has to code this functionality independently for the historical and real time versions of the EA.
Ok, but in that case on the same topic there is a reference to fxsaber's library for handling the Calender data in such a was as to work with both Live and in the Tester.
I don't know of it serves your needs but did you have a look at it?
I looks like for backtesting, MQL5 blocks access to the news calendar even if the calendar has news available. Here is the test I did, and may be a more expert person can comment, if this is the right test, and conclusion.
Basically, I coded an EA that displays the list of news for the EU from the current candle time to the next 24 hours. Every tick the list of news is re-printed.
If I run this code in real time, every tick I get the list of news in the next 24 hours. But if I run this same code in backtesting, say starting in January 2023 (when I know for certain the news calendar has news for the EU), the code returns an empty array.
This suggest that indeed one may have to code any news filter separately for backtesting and real time.
datetime From; // date to start looking for datetime Days=1; // number of days to look for datetime To; //holder variable of the end of the time period to check void OnTick() { From =iTime(_Symbol,PERIOD_D1,0); To = From + PeriodSeconds(PERIOD_D1)*Days; //--- country code for EU (ISO 3166-1 Alpha-2) string EU_code="EU"; //--- get all EU event values MqlCalendarValue values[]; //--- request EU event history since 2018 year if(CalendarValueHistory(values,From,To,EU_code)) { PrintFormat("Received event values for country_code=%s: %d", EU_code,ArraySize(values)); //--- decrease the size of the array for outputting to the Journal ArrayResize(values,10); //--- display event values in the Journal ArrayPrint(values); } else { PrintFormat("Error! Failed to receive events for country_code=%s",EU_code); PrintFormat("Error code: %d",GetLastError()); } //--- }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have been reading that news filters based on the MQL5 calendar do not work in the backtesting mode, and that a likely reason for this is that historical news data are rarely available and/or reliable.
Yet, when I look over the data available in the calendar, I see news back a few years. So could one backtest the effects of news for the times for which the MQL5 calendar has news? or is that capability disabled altogether in the backtesting part?