Look-ahead bias hides in the current bar's close
Posted: Sat Oct 31, 2026 6:56 pm
A classic backtesting error is using the close of the bar being formed to make a decision at the open of that same bar. In live trading, the close is unknown until the bar ends. A backtest that uses it sees the future.
For scalpers on one-minute bars, the slip is easy to make. An indicator calculated on the current bar, an entry rule referencing the close, and an order placed at the open of that bar form an invisible time machine. The results look wonderful and collapse in live trading.
Detecting the bias requires careful code review. Check which bar index each calculation uses. In MQL, index zero is the current forming bar, and index one is the last completed bar. Mixing them up is the usual culprit.
Another test is shifting the signals by one bar. If performance falls dramatically, the original version probably used future information.
A reliable approach is making all decisions on completed data, or on tick-by-tick data where the sequence is explicit.
Which test has been used to confirm that signals use only past information?
For scalpers on one-minute bars, the slip is easy to make. An indicator calculated on the current bar, an entry rule referencing the close, and an order placed at the open of that bar form an invisible time machine. The results look wonderful and collapse in live trading.
Detecting the bias requires careful code review. Check which bar index each calculation uses. In MQL, index zero is the current forming bar, and index one is the last completed bar. Mixing them up is the usual culprit.
Another test is shifting the signals by one bar. If performance falls dramatically, the original version probably used future information.
A reliable approach is making all decisions on completed data, or on tick-by-tick data where the sequence is explicit.
Which test has been used to confirm that signals use only past information?