CFDs and forex are complex instruments and come with a high risk of losing money rapidly due to leverage. Risk disclosure

Look-ahead bias: meaning and example

This page defines look-ahead bias, shows how it enters a backtest, and covers the edge cases experienced testers run into.

Extrade Pakistan editorial team ·

On this page
  1. What is look-ahead bias
  2. Look-ahead bias example
  3. Edge cases experienced testers check
  4. Where the term appears
  5. Related terms
  6. Frequent questions

What is look-ahead bias

Look-ahead bias is an error in a backtest where the strategy uses information that would not have been available at the moment the trade decision was made.

A backtest is a simulation of a trading rule on past prices. Its results are only meaningful if every decision in it uses data that existed at that point in time. When future data leaks in, the test looks much better than any live result could be.

Formally, a decision made at time t may use only the information set available up to t. Any input that is published, revised, completed or confirmed after t introduces look-ahead bias.

Past data (tuned)New datastart
Over-fitting: a strategy tuned to past data looks smooth on that data and often fails on data it has not seen. Test on a separate period and on a demo first. Illustrative example: made-up numbers for learning, not real prices or a broker's conditions.

Look-ahead bias example

This is a hypothetical case.

A tester writes the rule: "Buy at the day's open if the day closes above its moving average." The code checks the close of the current daily bar and then enters at the open of that same bar.

In real trading, the close is not known until the day ends, so the entry at the open could never have happened. The backtest still "knows" how the day ended, so it buys mostly on days that rose. The equity curve climbs almost smoothly, and the annualized return looks unusually high.

The fix is to base the signal on the previous bar's close and enter at the next bar's open. The same rule then usually shows far weaker results. Those weaker results are the realistic ones.

Edge cases experienced testers check

Where the term appears

A clean backtest does not predict future results. Leveraged CFD and forex trading can lose money fast, including with a well-tested rule. See risk management.

Frequent questions

What does look-ahead bias mean in simple words?

The backtest used information from the future, which a real trader could not have had at that moment.

How do I spot look-ahead bias in backtesting?

Check that every signal uses only completed bars and data already published. Then shift entries to the next bar and see whether the results collapse.

Is look-ahead bias the same as overfitting?

No. Look-ahead bias leaks future data into a decision. Overfitting tunes a rule too closely to past noise. Both make results look better than they are.

Can a demo account show look-ahead bias?

No. A demo account runs forward in real time, so future data is not available to it. That makes demo trading a useful check on a backtest. See the demo account page.

Related pages