Lookahead Bias
Lookahead bias is when a calculation uses information that was not yet available at that point in time — most often a higher-timeframe value requested before that timeframe's bar closed — producing signals and backtests that are impossible to reproduce live.

What it means
Lookahead bias is the backtester's original sin: letting the past see the future. In charting it appears mainly through higher-timeframe requests. If a 15-minute chart asks for the daily close and receives today's daily close while today is still trading, every 15-minute bar "knows" where the day will end. Signals built on that look prophetic in history and fail in real time.
In Pine Script the switch is explicit: `request.security(..., lookahead=barmerge.lookahead_on)` leaks the future; `lookahead_off` returns only the last completed higher-timeframe bar. Other sources include using the bar's high or low as an entry price (you could not have known the high until the bar closed) and pivots plotted at the pivot bar rather than at confirmation.
Lookahead is the mechanism behind a large share of repainting, and also behind backtests with absurd returns. Any strategy result should be checked for it before the numbers are believed.
How to identify it on a chart
- In code, search for `lookahead_on` and for fills at `high`/`low` of the signal bar.
- In backtests, look for win rates or Sharpe ratios far outside anything the market delivers.
- In bar replay, check whether higher-timeframe values on the chart change when the higher timeframe closes.
Worked example
A strategy buys the 5-minute close whenever the 4-hour candle is green — but reads the 4-hour with lookahead on. In history it buys at the start of every green 4-hour candle; live, it cannot know the candle is green until it closes. The backtest is worthless.
See it on the chart, read it in depth
Frequently asked questions
Is lookahead the same as repainting?
Lookahead is one cause of repainting; repainting is the visible effect. You can also repaint without lookahead by using the unclosed bar.
Is lookahead ever legitimate?
Only to align historical data for display when the offset is corrected explicitly; never for signals or entries.
How do Quantum Algo scripts avoid it?
Every higher-timeframe request uses lookahead off and reads the previous completed bar.
How do I check a backtest for it?
Replay it bar by bar; if the historical signals could not have been known at the time, the test has lookahead.
Related terms
See Lookahead Bias on your TradingView chart
Zeno reads Smart Money structure across timeframes and prints the entry, stop and targets — with a public record of every posted trade. The free indicators draw the concepts this page defines.