Look-ahead bias in backtests: how future information sneaks in
Look-ahead bias means that a backtest uses information that would not have been available at the moment the decision was made. It is one of the most common reasons a backtest looks excellent and a live strategy does not, and it is easy to introduce by accident.
What it looks like
A strategy that decides to buy at the open using that day's closing price is peeking. The code runs without errors and the equity curve looks wonderful, because the rule quietly knows how the day ended.
Common ways it leaks in
- Using the high, low or close of the current bar to decide an entry that is filled at the open or earlier in the same bar.
- Indicators that repaint, such as zigzag-style or centred calculations that change as new bars arrive.
- Combining time frames so that a higher time-frame bar is used before it has actually closed.
- Using economic data in its final revised form instead of as first released and at the time it was published.
- Misaligned time zones or timestamps between price data and other data sources.
- Normalising or optimising with statistics computed over the whole sample, including the future.
How to detect it
- Results that look too good: very high win rates, tiny drawdowns, near-perfect timing.
- Shift every signal by one bar. If performance collapses, the strategy may have relied on information it should not have had.
- Replay the strategy bar by bar and print exactly what data each decision could see.
- Compare the backtest with a forward test on new data, even on a practice account.
How to prevent it
- Separate the time of the decision from the time of execution, and fill at a price that was actually available afterwards.
- Use only completed bars for signals and lag them by one bar when in doubt.
- Prefer point-in-time data for anything that gets revised.
- Avoid indicators that repaint, or test them only on bars that are final.
- Keep out-of-sample data untouched until the design is finished.
Where TradeCC fits
When you describe a rule to CC, it asks about what the idea leaves open, and the draft states the date range, time zone and out-of-sample split before a historical backtest runs, which starts only after you confirm it in the conversation. You can also describe your own rules and data and ask CC to point out places where future information may have leaked in. It is a research aid, not a guarantee, and not investment advice.
Frequently asked questions
Is look-ahead bias the same as overfitting?
No. Look-ahead bias is using information that was not available at the time. Overfitting is tuning a strategy so closely to past data that it does not generalise. They often appear together and both make backtests look better than live results.
Can a platform's built-in tester have look-ahead bias?
The tester itself can be reliable, but the strategy you write or the indicators you use can still introduce it, and data quality and modelling mode affect results.
What is survivorship bias?
A different problem: testing only on instruments that still exist today, which leaves out those that failed or were delisted and makes historical results look better.