Overfitting (Curve Fitting) Definition: Overfitting is the error of tuning a trading strategy or model so closely to historical data that it learns random noise rather than a repeatable pattern. An overfitted strategy shows excellent past results but performs poorly on new data, because the quirks it was built around do not repeat.
What Is Overfitting?
Every price chart mixes two things: real patterns that may repeat and random movement that will not. When you adjust a strategy’s rules and settings until its past performance looks perfect, you inevitably start fitting the random part too. The result is a strategy that describes history in great detail but has little to say about the future.
The term comes from statistics, where a line or curve is “fitted” to data points. A simple curve captures the general trend, while a curve with enough bends can pass through every single point, including the outliers. That second curve fits the old data better and predicts new data worse.
Economist David Leinweber turned the problem into a famous joke. He showed that butter production in Bangladesh explained about 75% of the movement in the S&P 500 over a stretch of the 1980s and early 1990s, and adding American cheese production and sheep populations pushed the fit close to 99%. None of those series had anything to do with stocks: he had simply searched enough data to find a match by chance.
How Does Overfitting Work?
Overfitting grows with the number of choices you test. Each extra parameter, filter or rule gives the strategy another way to bend around past prices, and each extra test raises the chance that one combination looks brilliant by luck. If you try 1,000 variations, the best one will look impressive even if none of them has a real edge.
Imagine you build a BTC/USD strategy based on two moving averages, buying when the fast one crosses above the slow one. You test every fast length from 5 to 50 and every slow length from 20 to 200 on two years of data, then add a time-of-day filter and a volume filter. The winning setup, a 17-period and 43-period pair that only trades between 2 pm and 6 pm, turns $10,000 into $28,000 on paper.
You then run it on the following year, which the optimisation never saw, and the account falls to $8,800. The odd settings worked in the test period because they happened to dodge a few specific losing trades, not because 17 and 43 or the afternoon window mean anything to the market. Once prices moved differently, the strategy had nothing real to rely on.
Signs of an Overfitted Strategy
Fragile parameters: Results collapse when a setting moves slightly, for example from 17 to 18 periods. A genuine pattern should survive small changes.
Too many rules: Each extra condition that removes a few bad trades from the history adds curve fitting rather than insight.
Unrealistic statistics: A very high win rate, an almost straight equity curve or a Sharpe ratio far above what professional funds achieve usually means the test learned noise.
Big gap between periods: Strong results on the data used for tuning and weak results on fresh data are the clearest signal of all.
Overfitting vs. Underfitting
Overfitting and underfitting are opposite failures. An overfitted model is too complex and memorises noise, so it shines on past data and fails on new data. An underfitted model is too simple to capture a real pattern, so it performs poorly on both.
| Overfitting | Underfitting | |
|---|---|---|
| Model complexity | Too many rules and parameters | Too few to describe the pattern |
| Past results | Excellent | Weak |
| Results on new data | Much worse than the test | Similar to the test, and weak |
| Usual fix | Simplify, test out of sample | Add relevant information |
Why Is Overfitting Important for Traders?
Curve fitting is the main reason strategies that look profitable in backtesting lose money when traded live. Because the test results are the evidence traders use to commit capital, an overfitted backtest does not only waste time, it actively persuades you to risk money on noise.
Several habits reduce the risk. Split data into an in-sample period for building and an out-of-sample period you touch only once for the final check, keep rules few and logical, and prefer settings that work across a broad range rather than at one exact value. Walk-forward testing, which re-optimises on a rolling window and tests on the next unseen stretch, repeats this check many times.
None of these methods removes the danger entirely. Each time you look at out-of-sample results and go back to adjust the rules, that data leaks into the design and stops being truly unseen. Overfitting also compounds with survivorship bias, since a strategy tuned on a dataset of winners is fitted to an unusually favourable history, which is why serious algorithmic trading teams assume live returns will be lower than any backtest.
Key Takeaways
- Overfitting, or curve fitting, is tuning a strategy so closely to past data that it learns noise instead of a repeatable pattern.
- The risk rises with every extra parameter, rule and variation tested, because more choices make lucky matches more likely.
- Fragile settings, too many rules and a large gap between test and fresh-data results are the main warning signs.
- Overfitting is the opposite of underfitting, where a model is too simple to capture a real pattern.
- Out-of-sample and walk-forward testing reduce the problem, but every peek at unseen data weakens those checks.
Is optimising a strategy always overfitting?
No. Choosing sensible parameters is part of building any system, and it becomes overfitting when the parameters are tuned until they match noise. A sound strategy performs reasonably across a wide range of nearby settings, not only at one exact value.
Can a strategy with a short history be trusted?
Treat it with caution. A small sample with few trades makes it easy for random luck to look like skill, so a strategy needs enough trades across different market conditions before its results mean much.
Does machine learning make overfitting worse?
It can. Models with thousands of adjustable weights can memorise past price data almost perfectly, so they need strict out-of-sample testing and limits on complexity to avoid learning noise.