GoldTriEngine
EA Education

Overfitting: Why Perfect Backtests Fail When You Go Live

Overfitting, or curve fitting, is tuning a strategy until it fits the past perfectly, including its random noise. It looks brilliant in a backtest and fails live. The defences are simple rules, out-of-sample tests, walk-forward testing and fewer tuned parameters.

YeliasPublished 20 November 20262 min read

A perfect fit to the past is a warning sign

Imagine fitting a curve through ten points. With enough knobs you can draw a line that touches every point exactly. It describes the past perfectly, and it says nothing useful about the next point, because it has memorised the noise. A strategy tuned the same way does the same thing.

Optimisation tools make this easy. If you test thousands of combinations of settings on the same history, some of them will look excellent by pure chance. The more combinations you try, the better the best one looks, and the less it means.

How it happens

  • Too many parameters: each adjustable setting is another knob for fitting noise.
  • Too little data: a short history has few independent events, so chance dominates.
  • Testing and tuning on the same period: the result is measured on the data it was shaped by.
  • Choosing the best of many runs and reporting only that one.
Sign of a robust strategySign of an over-fitted one
Few settings, each with a clear reasonMany settings with odd-looking values
Works across a wide range of settingsOnly one narrow combination works
Similar results on data it never sawGreat on the test period, weak outside it
Works on related markets or periodsFalls apart when the start date moves
A good result should not depend on a lucky setting.

How to test against it

  1. Hold back data. Tune on one period, then test once on a later period the strategy has never seen (out-of-sample).
  2. Walk forward. Tune on a window, test on the next, then slide both forward and repeat.
  3. Nudge the settings. Move each by a little. If results collapse, the strategy is brittle.
  4. Test costs and spread higher than you expect.
  5. Run it forward on a demo account and compare with the backtest.

Frequently asked questions

How can I tell if a robot is over-fitted?

Ask how many settings were optimised, whether results hold on data after the tuning period, and whether live trading matches the backtest. A fragile result is a red flag.

Is optimisation always bad?

No. Optimising a few settings on enough data, then validating on unseen data, is sound. The problem is tuning many settings and trusting one run.

What is out-of-sample testing?

Testing on data that was not used to choose the settings. It is the closest a backtest gets to a real experiment.

Sources and method

  • Standard risk-management and statistics formulas. Every example in this lesson uses made-up round numbers to show how the maths works; none of them is a result or a forecast.
Y

Yelias, GoldTriEngine. We trade gold with an automated EA and publish every trade in public. Everything here is built from that live data. See the live account or the EA.

Not financial advice. This is education and research, not a recommendation to buy or sell anything. Trading gold and CFDs carries a high risk of loss, and past results, back-tests and forecasts do not guarantee future results. Read our risk disclaimer. Numbers in this article are computed by our own software from our own price data and trading account; drafting is assisted by AI. Written under the name Yelias.
Contact us