Hello,
I always had issues when creating indicators in MT5 that access data from different symbols and timeframes rather than current.
From documentation I found this in a lot of places.
For Expert Advisors and indicators, it is better to use the event model of handling. If during handling of OnTick() or OnCalculate() event, data receipt for the required timeseries failed, you should exit the event handler, relying on the access availability during the next call of the handler.
So, great, during day with markets opened there are no problems, at the first tick some timeseries can fail, and on the next one data are accessed correctly.
But what about weekends, where OnCalculate function is called only once, after OnInit and there are no incoming ticks to "re-trigger" OnCalculate function?
Do I need to work with OnTimer or am I missing something?
I think there is no way, just the strategy tester
The call of ChartSetSymbolPeriod with the same symbol and timeframe can be used to update the chart (similar to the terminal's Refresh command). In its turn, the chart update triggers re-calculation of the indicators attached to it. Thus, you are able to calculate an indicator on the chart even if there are no ticks (e.g., on weekends).

- www.mql5.com
Thanks!
No, read the documentation attentively.
int shift=iBarShift(_Symbol,PERIOD_H8,D'2019.01.01'); // Just an example of a statement which can fail in MTF if(shift==-1) { printf("MTF error..."); ChartSetSymbolPeriod(0,NULL,0); return(0); }
No, read the documentation attentively.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I always had issues when creating indicators in MT5 that access data from different symbols and timeframes rather than current.
From documentation I found this in a lot of places.
For Expert Advisors and indicators, it is better to use the event model of handling. If during handling of OnTick() or OnCalculate() event, data receipt for the required timeseries failed, you should exit the event handler, relying on the access availability during the next call of the handler.
So, great, during day with markets opened there are no problems, at the first tick some timeseries can fail, and on the next one data are accessed correctly.
But what about weekends, where OnCalculate function is called only once, after OnInit and there are no incoming ticks to "re-trigger" OnCalculate function?
Do I need to work with OnTimer or am I missing something?