This module is about a trap that catches careful testers in particular: overfitting. By the end of this lesson, you'll know what it is, and why a rule that fits the past perfectly can do badly on new prices. You'll see how it creeps into a strategy one sensible-looking rule at a time, and the signs that a strategy might be overfitted.
1 of 8
What you'll learn
- Spot overfitting. A strategy tuned too tightly learns the random wobble in past prices.
- Compare old and new data. A perfect fit on the past can miss new prices the most.
- Question each new rule. Extra rules can end up describing which past trades lost.
- Know the warning signs. Look out for rules with no reason, few trades and fussy settings.
- Write a reason for each rule. Do it before you see any test result.
Exercise
- Take a strategy sheet you've written, or one from The strategy library.
- Next to each rule, write one sentence on why it should matter in the market, before any Running a strategy’s exact rules over past prices to see which trades they would have taken.More in the glossary result.
- Mark any rule whose only reason is "it made the test better".
Quick check
1. A rule that fits every past wiggle perfectly is most likely to…
2. Which is a warning sign of overfitting?
3. Why can't you spot overfitting from the built-on data alone?
0 of 3 answered.
Finished this lesson?
Tick it off and keep your place
Read the full notes
Overfitting is tuning a strategy so tightly to past prices that it learns their random wobble. It looks excellent on the data it was built on and does worse on new prices.
- Tuning a strategy’s rules so closely to one stretch of past prices that they describe that stretch’s quirks more than anything that carries on.More in the glossary is tuning a strategy so closely to past prices that it describes their random wobble, the The small, random ups and downs in price that don’t follow any pattern that repeats. A rule tuned to noise fits the past but not new prices.More in the glossary, as well as anything that might repeat. It fits the past and does badly on new prices.
- Made-up dots: a straight line misses the old dots by about 0.5 on average and the new ones by about 0.3. A wiggly line through every dot misses the old ones by 0 and the new ones by 2.6. Perfect on the past, worst on the future.
- Made-up rules (wins 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, losses −1R): rule 1 gives +3R from 12 trades; "skip Tuesdays" lifts it to +6R; "skip if the last 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 was red" to +8R from 7 trades. On new prices: 6 trades, 0R.
- Signs: rules with no reason you could explain, very few trades left, exact settings that matter a lot, and a big drop on prices the strategy hasn't seen.
- More: Overfitting a trading strategy.
Worked example
Made-up numbersRules that fitted the wobble
Made-up numbers · wins +2R, losses −1R
- Rule 1 alone: 12 trades, 5 wins, 7 losses. 10R − 7R = +3R
- Add "skip Tuesdays": 3 losses gone. 10R − 4R = +6R
- Add "skip if the last candle was red": 2 more gone. 10R − 2R = +8R from 7 trades
- New prices: 6 trades, 2 wins, 4 losses. 4R − 4R = 0R
Every rule improved the past, but they described which trades happened to lose, not the market.
Your turn
DrillMade-up numbers · new prices · 8 trades · 3 wins at +2R · 5 losses at −1R
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.