Home › Guides › Look-Ahead Bias

TESTING TRAPFREENO ACCOUNTAUTOMATED TRADE BOTSLook-Ahead BiasWhy a good backtest can lieEDUCATION ONLY | NO SIGNALSEXAMPLE NUMBERS ARE LABELLEDAUTOMATED TRADE BOTSautomatedtradebots.com
A free page on look-ahead bias. Education only, with example numbers labelled.
TESTING TRAP

Look-Ahead Bias

Short answer

Look-ahead bias means a test uses information that was not available at the moment the trade would have been decided.

A backtest that quietly uses a number that did not exist yet looks brilliant. The bot then loses on live trading, because live trading never has that number.

The page explains the idea in plain words, works through the arithmetic with a table, and shows how it hits grid, martingale and DCA bots, then tells you what to check before you run one.

  • A worked example with real arithmetic
  • How it hits grid, martingale and DCA bots
  • How to check for it before you run a bot
  • No advice, no signals, no profit promises

Last reviewed 28 October 2026. Education only, not advice.

Free, no account Runs in your browser Worked numbers shown Not advice Examples labelled

Ready to go further

Next: a backtest result is only as good as its settings

Look-ahead bias fakes the signal. Overfitting fakes the settings. Read how fitting to noise works and how to check for it.

Reading time6 minutes
Worked exampleExact arithmetic
Tools linked0 on this page
Reviewed28 Oct 2026

What is included

  • What it is, in plain words
  • The formula or mechanism, with exact arithmetic
  • How it hits grid, martingale and DCA bots
  • A check you can run before you switch a bot on

Who it is for

  • People who run or plan to run a trading bot
  • Anyone reading a backtest or a bot sales page
  • Readers who want the numbers, not the pitch
  • Not advice, and not a signal service
Same rule, same 8 bars: result with and without a peek at the future (made-up)+7.0 ptsUses the bar's own close5 trades, no losers-3.5 ptsWaits for the next bar4 tradesMade-up prices. The only difference between the two bars is when the signal is allowed to see the close.
The picture for this page. Example numbers are made up unless the page says they were calculated.

Key facts

  • Look-ahead bias means a test uses information that was not available at the moment the trade would have been decided.
  • Four common forms: using a bar's close before it closes, indicators that repaint, future data inside normalisation or scaling, and adjusted or restated data.
  • In the made-up example below, the same rule earns +7.0 points when it sees the bar's own close and -3.5 points when it must wait for the next bar.
  • The standard checks are to run bar by bar, delay every signal by one bar and see if the result collapses, and compare backtest signals with live ones.
  • The bias is often invisible in the settings screen. It sits in how the data is fed to the rule.

What look-ahead bias is

At any real moment, a bot knows the past and nothing else. A backtest can break that by accident. It holds the whole history in memory, so a rule can reach for a value that, on that day, had not happened yet. The test then trades on the future.

The results look great because they are great, in the one place that does not exist: the test. Live, the future is not available, and the edge goes with it.

The four common types

  • Using the close before the bar closes. A rule says "enter if the bar closes above the average" and the test enters at that bar's open or at a price inside the bar. At the open, nobody knows where the bar will close. The test is trading with the answer.
  • Using the high or low of the current bar. "Buy at the lowest price of the bar" or a stop placed using the bar's high needs the whole bar. Live, the low is only known after the bar ends.
  • Indicators that repaint. Some indicators change their past values as new bars arrive, such as zigzag and swing-point tools that only confirm a turning point later and then redraw it as if it were known earlier. In a backtest the finished picture is used for every bar, so every turn looks perfectly caught.
  • Future data in normalisation. Scaling a series with its overall minimum, maximum, mean or standard deviation uses numbers that depend on later data. The scaled value at bar 100 depends on what happened at bar 1,000.
  • Adjusted and restated data. Prices adjusted for splits and dividends, or economic figures later revised, show values that were not what traders saw at the time. A rule built on the final revised number trades on information that arrived weeks later.

A worked example: same bar close

Here is a rule with no edge at all: "if the bar closes higher than it opened, go long." Eight made-up bars, with the open and close of each:

BarOpenCloseClosed up?Peeking rule: buy at this open, sell at this closeHonest rule: buy at next open, sell at next close
1100.0101.0yes+1.0-2.0
2101.099.0no0.00.0
399.0100.5yes+1.5+1.5
4100.5102.0yes+1.5-2.0
5102.0100.0no0.00.0
6100.0101.5yes+1.5-1.0
7101.5100.5no0.00.0
8100.5102.0yes+1.50.0
Total+7.0-3.5

All prices are made up. The peeking rule decides using the close and then trades from the open of the same bar. It can only ever trade bars that went up, so it takes 5 trades, wins all of them and makes +7.0 points. The honest rule can only act after the bar has closed, so it enters at the next bar's open and has to take whatever that bar does. It takes 4 trades and makes -3.5 points. In this tiny sample, the "edge" was entirely the peek.

The same thing happens with highs and lows in less obvious ways. If a rule says "buy at the low of the bar when price touches the average", the test fills at the best price of the bar by definition. No live order is assured that fill.

Running total, in points: peeking rule versus honest rule (made-up bars)-4048Bar 1Bar 2Bar 3Bar 4Bar 5Bar 6Bar 7Bar 8+7.0-3.5Bar numberMade-up prices from the table above. Amber peeks at the close, red waits for the next bar.
The two lines use the same rule on the same bars. The gap between them is the size of the lie.

How it hits bots

  • Grid bots: a backtest that assumes each grid level fills at exactly the level price whenever the bar's range touched it uses the high and low of the bar. It cannot tell whether the low or the high came first, and that order decides whether the bot was in or out.
  • Martingale bots: if the "take profit hit" check uses the bar's high and the "stop" check uses the low, the order of events inside a bar matters. A test that assumes profit first ignores bars where the loss came first.
  • DCA bots: buying at the day's low or a weekly "dip" identified with the full week's data peeks at the future.
  • EAs: a published EA that opens on "bar 0" and uses indicator values from bar 0 can trade on a candle that is still moving. Results on a completed bar differ from results while it forms.

How to check for it

  • Run bar by bar. Feed the rule one bar at a time and let it see only what existed. A rule that cannot run this way is a warning.
  • Delay every signal by one bar. If the result collapses, as it did above, the rule relied on information from the same bar. Some real rules lose a little from a delay, and that is fine. A collapse is the sign.
  • Compare backtest and live signals. Record the live signal and rerun the same time period in the backtest. The two should match, bar for bar. A signal that appears in the backtest and never appeared live was drawn after the fact.
  • Look at the indicator's rules. Does it change old values? Does it confirm turning points with later bars?
  • Check the data source. Is the data point-in-time, as it was known then, or adjusted or revised later?
  • Be suspicious of perfection. A smooth curve with a very high win rate and no deep drawdown is often a data problem before it is a good strategy. See overfitting for the other common cause.

What it does not tell you

Passing the delay test does not mean the strategy has an edge. It means the test was not peeking in this particular way. Other biases remain, such as survivorship bias in the data and fitted settings. Look-ahead bias is also not always an obvious bug: a few lines of code can hide it, and a trading platform's built-in tester can hide it in how it models the current bar. Read how your tester handles the open bar, and run the delay check on anything you rely on.

Finally, the only complete test is forward testing on data that did not exist when the rule was written.

FAQ

Frequently Asked Questions

How do I know if my backtest has look-ahead bias?

Delay every signal by one bar and rerun. If the results collapse, the rule probably used information from the same bar. Also check whether any indicator repaints and whether the data was adjusted or revised after the fact.

Why does using the bar close matter?

Because the close is only known when the bar ends. A rule that decides on the close can only trade from the next bar. Entering at the open of the same bar uses a price that came before the information.

What is a repainting indicator?

An indicator that changes its past values when new bars arrive. In a backtest it shows its final, corrected picture on every bar, so signals look perfectly timed. Live, they appear late or disappear.

Can a built-in strategy tester have look-ahead bias?

It can, depending on how it models the current bar and what it lets the rule read. Check the tester's documentation for how it handles the open bar, highs, lows and order of events within a bar.

Is look-ahead bias the same as overfitting?

No. Look-ahead bias is using data from the future. Overfitting is tuning settings to the past. They can occur together, and both make a backtest look better than live trading will be.

Are the numbers on this page real?

Example numbers are made up to show how the maths works, and the page says so. A figure only counts as exact when the page says it was calculated on a stated date. Nothing you enter in a calculator leaves your browser.

Can I use this to decide whether to run a bot?

It can show whether a bot's numbers hold together and how much an account can lose. It cannot say what the market will do, and it is not advice. Use it to ask better questions, then read the terms of your own broker or exchange.

Is this financial advice?

No. It explains a testing error in general terms. The bar prices are made up for illustration and do not describe any market.

Know the Risk Before You Run It

Free calculators and guides, added every week. Leave your details and we will email you when new ones go up.

Trading carries a risk of loss