Look-ahead bias happens when a backtest uses information that would not have been available at the moment of the decision. It can make a worthless rule look brilliant, and it is surprisingly easy to introduce by accident.
Common ways it sneaks in
- Trading at the close that generated the signal. If your rule needs the closing price, you only know it once the bar has finished. Filling at that same close assumes you could act on it instantly.
- Using a bar’s high or low before the bar is complete.
- Revised data. Some datasets are corrected after the fact; the original numbers traders saw were different.
- Indicators computed with future values, for example a centered moving average or a normalization over the whole history.
How Backte.st avoids it
The engine reads signals only from completed candles and fills orders at the next open. A rule that fires on Monday’s close is executed at Tuesday’s open, which is the earliest price you could realistically get.
This is stricter than some backtesting tools, and results can look worse as a result. That is intended.
The delayed-entry check
Even with honest fills, a strategy can depend heavily on precise timing. The Delayed entry check fills every order one bar later, at the second open after the signal.
- If the result barely changes, the strategy isn’t relying on split-second timing.
- If it collapses, most of the profit comes from the very first bar after the signal. That edge is fragile: real-world delays, gaps and missed orders can eat it.
A related trap: survivorship
Look-ahead bias is about when you knew something. A close cousin is knowing which markets would still exist. Choosing today’s winners to test a strategy on yesterday’s data is survivorship bias.
Checklist
- Can every input to the rule be known when the decision is made?
- Does the fill happen after the signal, at a price you could get?
- Does the result survive a one-bar delay?
Run any strategy in the lab and compare the delayed-entry return to the base result.