
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Thanks people,
checking the Bars value solved the problem.
Always check the "Bars" variable to make sure the index into Time[], High[], Low[], Close[], etc. will be valid or not.
This is especially important when running under the Strategy Tester with no "Use Date" limits, and during the first bar.
There will be no "mismatch" reported, because there is no mismatch. It simply just has the current bar data available.
Please can you explain what you mean by checking? I have the same issue. It is a pattern recognition EA that look for previous candles so use ratesH1[1], ratesH1[2], etc values and in the strategy tester it crash directly at the start because array out of range but in live markets work fine
Please can you explain what you mean by checking? I have the same issue. It is a pattern recognition EA that look for previous candles so use ratesH1[1], ratesH1[2], etc values and in the strategy tester it crash directly at the start because array out of range but in live markets work fine
If I am not mistaken, this could help
https://www.mql5.com/en/docs/series/bars
You should not access time series data in the OnInit() event handler, as the data may not be available yet (e.g. after opening MetaTrader and it is still not connected to the trade server or the chart data has not loaded yet).
Instead, do it in OnTick() when receiving the first tick.
This assumes every bar every exists — they don't. What if there are no ticks during a specific candle period? There can be minutes between ticks during the Asian session, think M1 chart. Larger charts, think weekend, market holiday (country and broker specific), requires knowledge of when your broker stops and starts (not necessary the same as the market.)
"Free-of-Holes" Charts - MQL4 Articles (2006)
No candle if open = close ? - MQL4 programming forum (2010)
Just compare the bar index to Bars.