Curve Fitting in Trading: What It Is and How to Avoid It
Curve fitting in trading is tuning a strategy so closely to past prices that it captures noise rather than a repeatable pattern. You avoid it by testing on data the strategy never saw, keeping rules simple and demanding enough trades.
By GSB Pro · Updated
On this page
What is curve fitting in trading?
Every trading strategy has rules and settings: a moving-average length, an RSI level, a stop size. When you test many settings on past data and keep the best, you are fitting the strategy to that data.
Some fitting is unavoidable. The problem starts when the settings fit the random wiggles of one stretch of history. The backtest then looks smooth, but the pattern it learned was never real, so it tends to fall apart on new data.
A simple test: if a small change to a setting wrecks the result, the strategy is probably fitted to the past. A strategy with a real edge usually works across a range of nearby settings.
Curve fitting vs overfitting
Most traders use the two terms to mean the same thing. Strictly, they differ a little:
- Curve fitting is fitting any model to data. All optimisation does some of it, and a little is fine.
- Overfitting is fitting too closely, so the model learns noise as well as signal. It looks better on the data it was built on and worse on everything else.
In trading, "curve-fit" is usually shorthand for overfitted. This guide uses it that way. What matters is not the label but whether the strategy still holds up on data it has never seen.
Why generated and optimised systems are prone to it
The more combinations you test, the more likely some will look good by luck alone. A strategy generator or genetic algorithm can test millions of combinations of indicators, parameters and exits. That is its strength and its main risk.
If you test enough random rules, a few will produce a beautiful equity curve on past data. Those lucky rules look just as good as a real edge on the build data. The only fair way to tell them apart is data the search never used.
Hand-built strategies are not immune. Each time you tweak a rule after looking at the results, you add another hidden test. Over months, a trader can fit a strategy to history without ever running an optimiser.
Warning signs of a curve-fit strategy
- Excellent in-sample, poor out-of-sample. A big drop from the build period to the test period is the clearest sign.
- The equity curve changes character where the build data ends and the test data begins.
- Too few trades. A handful of trades can look great by chance. The result means little.
- A knife-edge setting. Results collapse when one parameter moves a step either way.
- Too many rules and filters, each removing a few losing trades from the past.
- Long flat stretches, sudden cliffs, or all the profit at the very end of the test.
- It only works on one bar size or one market, and nowhere nearby.
One warning sign does not prove a strategy is curve-fit. Several together usually mean you should move on.
How to avoid curve fitting: the main defences
No single test catches every curve-fit strategy. Each defence below stresses a different weak spot, so use them together.
| Defence | What it does | What it catches |
|---|---|---|
| Out-of-sample data | Holds back part of the history from the build | Strategies that only work on the data they were built on |
| Walk-forward analysis | Re-optimises on one window, tests on the next unseen window, and repeats | Settings that only worked in one market period |
| Other bar intervals and markets | Runs the same rules on different data | Rules tuned to the exact prices of one data series |
| Monte Carlo | Repeats a test many times with random changes | Results that depend on one lucky sequence or setting |
| Simplicity | Limits the number of rules and parameters | Strategies with enough moving parts to fit anything |
| Enough trades | Sets a minimum sample size | Results that are just a few lucky trades |
Out-of-sample testing. Build on one part of the data and test on another. Keep a recent period completely untouched for a final check. Once you change a strategy after looking at its out-of-sample results, that data has become in-sample.
Walk-forward analysis. A single split gives one result from one period, which may be lucky. A walk-forward tests many periods, the way you would re-optimise in live trading. Our walk-forward analysis guide explains it in full.
Other bar intervals and markets. A real pattern often shows up, weaker, on related data. A rule that only works on 30-minute bars of one market may be fitted to that one series.
Monte Carlo. Repeating a test with randomised settings or trade order shows a spread of outcomes, not one number. See our Monte Carlo trading guide.
Simplicity and sample size. Fewer rules leave less room to fit noise. More trades make a result harder to produce by chance. Remove any rule that only changes a handful of trades.
How GSB's workflow applies each defence
Genetic System Builder (GSB) searches huge numbers of indicator and parameter combinations, so it has to take curve fitting seriously. Here is how each defence appears in the workflow the Strategy Guide teaches.
Out-of-sample data. GSB builds on training data only and keeps the rest as test data. Its Fitness score is worked out on the training part. In the results grid, red column headings are training and green are test, so a big drop is easy to spot. GSB's developer, Peter Zwag, keeps the most recent year or two out of GSB entirely. He also holds data back with Nth days, which alternate in-sample and out-of-sample days. See Building Trading Strategies and Peter's Build Rules.
Walk-forward. Each shortlisted system is walked forward, and the joined out-of-sample curve (WF OOS) is what you judge. The Strategy Guide's pass marks are anchored stability above 40, rolling stability of 62 or more, and walk-forward efficiency above 60%. An identical second walk-forward should give a similar result. Details are on Walk-Forward Optimization.
Other bar intervals. GSB can verify a finished system on other data streams. Peter tested this on Nasdaq futures in November 2024. He verified a 30-minute system on 15, 20, 40 and 60-minute data. That predicted out-of-sample results far better than noise, nearby bar sizes or other index markets. GSB reports VS (how many verification streams passed) and VSS (how much results degrade on average).
Other markets. Trademaid's examples include building on crude oil and verifying on heating oil and unleaded gas. But Peter's own test found other index markets predicted little for his Nasdaq system. Treat related-market checks as one input, not a verdict.
Monte Carlo. Since build 68.45, GSB has a Monte Carlo walk-forward. It reruns a random-space walk-forward many times, so you see the spread of results. Many better and many worse is fine; most results much worse is a red flag. Monte Carlo on a finished portfolio is in Portfolio Analyst Pro. Both are covered on Validation and Robustness.
Simplicity. In the starter settings file, each system uses up to three indicators. Peter's rules say change one setting at a time, and don't turn every option on. A two-pass method picks a short list of about 10 indicators before the main build.
Enough trades. The starter settings file rejects systems with fewer than 100 training trades. When selecting, the Strategy Guide looks for about 200 or more trades over the full period. Selecting Trading Systems gives the full checklist.
Families and objective rule tests. GSB groups systems that use the same indicators into families. You judge the whole family, not just its best member, because the top one flatters the rest. Peter also tests any selection rule by splitting about 300 systems into top and bottom thirds and comparing their out-of-sample results.
What these checks can and can't do
Passing them makes a system less likely to be curve-fit. No test can show it will be profitable in future. All GSB results are hypothetical backtests. The Robustness Lab shows the checks side by side.
Habits that undo the tests
- Re-optimising after seeing out-of-sample results. That data is now in-sample.
- Filtering on the full period, which turns every survivor into an in-sample pick.
- Picking one beautiful curve out of thousands. It looks convincing because it was chosen to.
- Relying on one train-and-test split instead of several checks.
- Setting costs to zero. Commission and slippage make a backtest more honest.
Keep a test log: what you tested, the result, and why you kept or rejected each system. It is the simplest guard against fooling yourself. To learn the full process step by step, see the free GSB Pro training.
Frequently asked questions
What is curve fitting in trading?
Curve fitting is tuning a strategy's rules and settings so closely to past prices that it captures random noise. The backtest looks strong, but the pattern was never real, so the strategy tends to fail on new data.
What is the difference between curve fitting and overfitting?
Curve fitting strictly means fitting any model to data, which all optimisation does to some degree. Overfitting means fitting too closely, so the model learns noise. In trading the two terms are usually used to mean the same thing.
How do you avoid curve fitting?
Test on data the strategy never saw, using out-of-sample periods and walk-forward analysis. Check it on other bar intervals or related markets, use Monte Carlo, keep the rules simple and require enough trades.
Are automatically generated trading strategies curve-fit?
They are prone to it, because a generator tests so many combinations that some look good by luck. Whether a given strategy is curve-fit depends on how it holds up on data the search never used.
Does walk-forward analysis prevent overfitting?
It reduces the risk but does not remove it. Walk-forward is one layer of checking, best combined with a final untouched period, verification on other data and realistic costs.
How many trades do I need to trust a backtest?
There is no fixed number, but more is better. GSB's starter settings reject systems with fewer than 100 training trades. The Strategy Guide looks for about 200 or more over the full period.
Try it on your own market
Start a free 14-day GSB trial and learn the method with our free 53-lesson video course. GSB Pro is an authorised Trademaid reseller and earns a commission if you buy.