Advertisement IC Markets

Look-ahead bias hides in the current bar's close

Share, develop, and backtest custom MQL4/MQL5 Expert Advisors, Python data-scraping scripts, trading bots, and automated market alert systems.
Post Reply
Amanhasnoname
Posts: 1506
Joined: Fri Oct 30, 2026 9:45 am

Look-ahead bias hides in the current bar's close

Post by Amanhasnoname »

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?
Recommended broker for automated trading & scalping IC Markets
Post Reply