Skip to content
All library documents

Measuring Stop and Target Ambiguity in OHLC Backtests

Article MQL5 code base

Summary

The document examines how one-minute OHLC backtests can misclassify bracketed trades when a bar touches both the stop and target. Because OHLC records prices but not their sequence within the bar, a tester must assume an intrabar path; real tick data can reveal which level was reached first. The described diagnostic opens virtual trades around each bar’s open, then compares the tester’s assumed outcome with the tick sequence whenever both levels are touched.

It sweeps bracket distances and reports results for XAUUSD over 30 days and 27,844 virtual trades. At 20 points, 62.6% of trades were contested and 23.84% were resolved the wrong way; at 100 points, the figures were 8.9% and 1.66%. Wider brackets showed lower ambiguity in this sample, with none contested at 1,000 points. These findings are specific to the symbol, period, and setup, not universal thresholds. The tool requires real tick history, allows trades to remain unresolved after a configured horizon, and reads data without placing orders.

Key ideas

  • OHLC bars omit intrabar price order, so a bar touching both a stop and target can leave a backtest outcome ambiguous.
  • The diagnostic compares an assumed OHLC path with real tick order for contested virtual trades.
  • The reported ambiguity declines as bracket distances widen in the stated XAUUSD sample.
  • Results depend on the symbol, date range, bracket setup, and availability of real tick history.
  • Trades that do not reach either level within the configured horizon remain unresolved.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.