I know some might say "just use tick data for backtesting." The reason I rely on M1 data is efficiency. When optimizing an EA, we often run tens of thousands of backtest passes, and M1‑based tests can complete in under 10 seconds, whereas tick‑based tests are orders of magnitude slower. Until this bug is addressed, my current workaround is to force all EAs that use stops to close positions before the Friday market close, just to avoid weekend gaps. This obviously limits the strategy's exposure and is not ideal.
Hello everyone,
I have encountered an issue when backtesting an Expert Advisor in the MT5 Strategy Tester using M1 data (e.g., "Open prices only" mode). During price gaps where the new bar's open price significantly exceeds the stop loss level (in the direction that would trigger the stop), the backtest result shows that the stop loss is still executed exactly at the stop price, rather than at the actual open price.
For example, consider a long position:
-
Friday close: 1.1000
-
Stop loss: 1.0950 (placed below the close)
-
Monday open: 1.0900 (gap down, well below the stop)
-
In reality, the stop should be triggered at the open price 1.0900.
-
However, in the M1‑based backtest, the trade is closed at 1.0950 (the stop level), as if the price never opened beyond it.
This discrepancy does not occur when using real tick data for backtesting; there the stop is correctly filled at the open price as expected.
It is important to note that this issue is not limited to weekend gaps. It can happen whenever two consecutive bars are not continuous in time – i.e., whenever the open price of a new bar differs from the close price of the previous bar. The problem simply becomes more noticeable during larger gaps like weekends.
To improve the accuracy of backtests on higher timeframes, I suggest that developers implement additional logic to handle gap openings. This would make the simulation more realistic by ensuring that when a bar opens beyond a stop level, the stop is filled at the actual open price (as would happen in a live market).
Has anyone else observed this behavior? Any thoughts or workarounds would be appreciated.
Thanks!
This is expected in "Open prices only".
This model does not simulate intra-bar price movement, so stops are evaluated using bar data and filled at the stop level.
Only real tick testing reproduces gap execution at the actual open price.
This is expected in "Open prices only".
This model does not simulate intra-bar price movement, so stops are evaluated using bar data and filled at the stop level.
Only real tick testing reproduces gap execution at the actual open price.
Thank you, Oleksandr, for the explanation. There was a description error in the translation software in my previous post. My backtest is actually configured with "1-minute OHLC" mode. In this mode, backtest results usually execute at accurate TP/SL levels, which is close to live trading.
However, the issue we discussed earlier still exists: when a price gap occurs (e.g., over the weekend) and the new bar's open price is beyond my stop loss level, the backtest result shows the stop being filled at the stop price, not at the actual open price. When I run the same test using real tick data, the stop is correctly filled at the open price.
This discrepancy affects any discontinuity between bars, not just weekend gaps. For strategies that rely on precise stop placement, this significantly impacts backtest accuracy, especially around gaps.
I hope this clarifies the issue, and I would encourage the developers to consider improving gap handling in OHLC-based backtest modes to better reflect real market conditions. Until this bug is addressed, my current workaround is to force all EAs that use stops to close positions before the Friday market close, just to avoid weekend gaps. This obviously limits the strategy's exposure and is not ideal.
Thanks again for the discussion.
- 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 everyone,
I have encountered an issue when backtesting an Expert Advisor in the MT5 Strategy Tester using M1 data (e.g., "Open prices only" mode). During price gaps where the new bar's open price significantly exceeds the stop loss level (in the direction that would trigger the stop), the backtest result shows that the stop loss is still executed exactly at the stop price, rather than at the actual open price.
For example, consider a long position:
Friday close: 1.1000
Stop loss: 1.0950 (placed below the close)
Monday open: 1.0900 (gap down, well below the stop)
In reality, the stop should be triggered at the open price 1.0900.
However, in the M1‑based backtest, the trade is closed at 1.0950 (the stop level), as if the price never opened beyond it.
This discrepancy does not occur when using real tick data for backtesting; there the stop is correctly filled at the open price as expected.
It is important to note that this issue is not limited to weekend gaps. It can happen whenever two consecutive bars are not continuous in time – i.e., whenever the open price of a new bar differs from the close price of the previous bar. The problem simply becomes more noticeable during larger gaps like weekends.
To improve the accuracy of backtests on higher timeframes, I suggest that developers implement additional logic to handle gap openings. This would make the simulation more realistic by ensuring that when a bar opens beyond a stop level, the stop is filled at the actual open price (as would happen in a live market).
Has anyone else observed this behavior? Any thoughts or workarounds would be appreciated.
Thanks!