Advertisement IC Markets

Look-ahead bias hides in bar-close logic

Share, develop, and backtest custom MQL4/MQL5 Expert Advisors, Python data-scraping scripts, trading bots, and automated market alert systems.
Post Reply
Fairman
Posts: 4650
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

Look-ahead bias hides in bar-close logic

Post by Fairman »

Look-ahead bias hides in bar-close logic

A backtest uses the close of the current bar to decide an entry at the open of the same bar. This is impossible in reality, since the close is not known until the bar ends.

The error is easy to make. An indicator calculated on the close, a condition triggered by the high of the bar, and an entry at the bar's open produce flattering results.

For scalpers on short timeframes, the effect is large. Many trades depend on small moves within bars, and any knowledge of the bar's outcome gives a huge edge.

Checking for it means reading the code or the rules carefully. Every decision should use only data available at the moment of the decision. Entries should be placed at the open of the next bar, or on a tick within the bar using only prior ticks.

A result that looks too good is the usual hint. Equity curves with almost no drawdown are suspicious.

Has the logic been checked for any use of information that would not have been available at entry time?
It’s Fairman :geek:
Recommended broker for automated trading & scalping IC Markets
Post Reply