CFDs and forex are complex instruments and come with a high risk of losing money rapidly due to leverage. Risk disclosure

Overfitting (curve fitting)

This page explains what overfitting means in backtesting, shows a hypothetical example, and lists the terms that go with it.

Extrade Pakistan editorial team ·

On this page
  1. Overfitting meaning
  2. A hypothetical example
  3. Where you meet the term
  4. Precise definition and edge cases
  5. Related terms
  6. Frequent questions

Overfitting meaning

Overfitting, also called curve fitting, is tuning a trading strategy so closely to past price data that it learns the random noise of that period instead of a pattern that repeats.

An overfitted strategy produces an impressive backtest and then performs much worse on data it has not seen. A backtest is a test of trading rules on historical prices.

Past data (tuned)New datastart
Over-fitting: a strategy tuned to past data looks smooth on that data and often fails on data it has not seen. Test on a separate period and on a demo first. Illustrative example: made-up numbers for learning, not real prices or a broker's conditions.

A hypothetical example

A trader builds a moving-average crossover system for a currency pair. To find good settings, they run an optimisation over a wide grid of inputs:

The optimiser tests every combination on the same stretch of history and picks the one with the highest profit. The resulting equity curve rises smoothly with shallow drawdowns.

The trader then runs the chosen settings on a later period that was not used in the optimisation. The curve goes flat or falls. The weekday filter had only removed a handful of losing trades that happened by chance. The exact moving-average lengths were not special either; neighbouring values gave much weaker results.

The "edge" lived in that particular sample, not in the market. Traded live with leverage, such a system can lose money fast, because the trader trusts results that were never real.

Where you meet the term

Precise definition and edge cases

In statistics, a model is overfitted when it has more free parameters or flexibility than the data can support. It then fits the in-sample data (the data used to build it) better than a simpler model, while making larger errors out of sample (on new data).

Points experienced traders check:

A good out-of-sample result lowers the risk of overfitting but does not remove it. Market regimes change, and fat tails and black swan events rarely appear in a limited sample.

Frequent questions

Is curve fitting the same as overfitting?

Yes. In trading, the terms are used interchangeably for tuning rules to past noise.

Does optimisation always cause overfitting?

No. Optimisation is a tool. Overfitting comes from too many parameters, too little data, or picking the single best result without testing it out of sample.

How do I spot an overfitted backtest?

Look for very smooth results, many filters, few trades, and settings whose performance collapses when changed slightly. Then test on data that was not used to build the strategy.

Does a demo account prove a strategy is not overfitted?

A demo account adds forward data, but a short demo period is still a small sample. It does not prove that a strategy will make money.

Related pages