The first family of ways a test can flatter a strategy is looking ahead. By the end of this lesson, you'll be able to spot look-ahead bias. That's when a test uses a price that wasn't known yet at the moment of the decision. You'll watch one made-up trade flip from a win to a loss once it's fixed. Then you'll see the common places it hides, and a simple check you can run on any rule.
1 of 7
What you'll learn
- Spot look-ahead bias. It uses a price not known yet and flatters every signal.
- Enter at the next open. A fair entry can turn a test win into a loss.
- Wait for candles to close. A high, low or range can still change until it ends.
- Log signal and entry times. The entry time can never come before the signal time.
- Assume the worst. If one candle hits both stop and target, count the stop.
Exercise
- Take one of your past test logs, or replay ten signals of any rule from The strategy library.
- Add two columns, signal time and entry time, and fill them in.
- Then check that no entry time is earlier than its signal time.
Quick check
1. A rule needs a candle to close above a level. When is the earliest honest entry?
2. One candle reaches both the stop and the target. What does a cautious test count?
3. Why does look-ahead bias matter so much over many trades?
0 of 3 answered.
Finished this lesson?
Tick it off and keep your place
Read the full notes
Look-ahead bias is when a Running a strategy’s exact rules over past prices to see which trades they would have taken.More in the glossary uses a price that wasn't known yet at the moment of the decision, such as entering at a candle's open because of how it closed. It makes every signal look better than it could have been.
- A backtest mistake: using a price the strategy couldn’t have known yet at the moment it made its decision.More in the glossary is when a test uses a price that wasn't known yet at the moment of the decision. It always flatters the strategy, on every signal.
- Made-up example: buy when a 5-minute One bar on a price chart. It shows where price opened and closed, and the highest and lowest it reached, in one stretch of time.More in the glossary closes above the high before it, An order that closes a trade if price reaches a level you set against it. It aims to limit the loss, but in a fast market it can fill at a worse price.More in the glossary 4 points, An exit order that closes a trade when price reaches a level you choose in your favour.More in the glossary 6. Entering at the signal candle's open (5,003.00) wins +$30; the honest entry, the next open (5,006.50), loses −$20.
- Other places it hides: acting on a candle's high, low or close before it finishes; trading a range such as the The highest and lowest prices in the first minutes of a trading session, over a length of time you choose.More in the glossary before it's finished; a higher-How much time each candle covers, such as 1 minute or 1 hour.More in the glossary line set up to show the finished day too early (TradingView's TradingView’s own programming language, used to write the indicators and strategies that run on its charts.More in the glossary guide calls this leaking future data into the past); a candle that touches both stop and target.
- The check: for each decision, ask which candles had closed. Log a signal time and an entry time on every row; the entry can never come first. When one candle hits both, count the stop.
- A chart feature that hides the candles after a point you choose, then shows them again one at a time, so you can practise on past prices without seeing ahead.More in the glossary hides the candles to the right, which helps. More: Look-ahead bias.
Worked example
Made-up numbersOne chart, two results
Made-up numbers · 1 A small futures contract on the S&P 500, traded at CME Group. Each point is worth $5, and its smallest step of 0.25 is worth $1.25.More in the glossary · 1 point = $5 · stop 4 points, target 6 · before costs
- Signal: the 10:05 candle closes at 5,006.50, above the 5,004.00 high before it, at 10:10
- Look-ahead entry at its open, 5,003.00: target 5,009.00 hit. +6 points = +$30 (A result measured in units of the amount at risk. If a trade risks 4 points, 1R is 4 points and a 6-point gain is +1.5R.More in the glossary)
- Honest entry at the next open, 5,006.50: stop 5,002.50 hit. −4 points = −$20 (−1R)
- The entries are 3.5 points, 14 The smallest step a price can move. On many stock index futures that’s 0.25 of a point.More in the glossary, apart
The same signal flips from a win to a loss once the test only uses what was known at the time.
Your turn
DrillMade-up numbers · signal candle opened at 5,010.00 · next candle opens at 5,012.25 · a test entered at 5,010.00
Trading is risky. You can lose money. Test results are hypothetical, and a good test doesn't mean future profits. This lesson explains how testing works. It isn't advice.