Blog

Overfitting: Why Your Optimized EA Fails Live

TradeSmithy Team4 min read

Short answer: overfitting — or curve fitting — is tuning an Expert Advisor's rules and parameters until they match the noise in historical data instead of a repeatable pattern. The backtest looks excellent because the EA has effectively memorised the past; on new data the "edge" disappears. The defences are fewer parameters, testing on data you did not tune on, and preferring settings that work across a broad range over the single best result.

How does overfitting happen?

Every time you look at a backtest and change something, you fit the strategy a little more to that history. Individually harmless, together fatal:

  • Too many parameters. Five indicators with three settings each is fifteen dials. With enough dials, any history can be matched.
  • Too many optimisation passes. Test ten thousand combinations and some will look brilliant by pure chance.
  • Too little data. Forty trades cannot distinguish skill from luck.
  • Rules added to dodge specific losses. "Don't trade on the third Tuesday" fixes the backtest and nothing else.
  • Judging on the same data you tuned on. The most common mistake of all.

Warning signs in your results

SignWhat it suggests
A sharp peak in the optimisation results, with neighbours much worseThe "best" setting is luck; a real edge degrades gradually
Profit factor above 3 on hundreds of tradesToo good to be structural
Most profit from a handful of tradesThe result depends on a few events
Great in-sample, poor out-of-sampleClassic overfit
Many parameters, few tradesToo many degrees of freedom for the data

In the MT5 optimiser, look at the results as a 2D or 3D chart of two parameters. A robust strategy shows a plateau — a broad region where most settings are profitable. An overfit one shows a lone spike.

Defences that work

1. Fewer parameters

Every parameter you optimise should earn its place. A common rule of thumb is to have at least a few dozen trades per optimised parameter.

2. Out-of-sample testing

Tune on one period, test once on a later period you never looked at. MT5's Forward setting reserves part of the range for exactly this. More in backtest vs forward test.

3. Walk-forward testing

Repeat tune-then-test across several consecutive windows, so the strategy has to prove itself more than once. We cover it in a separate post on walk-forward optimisation.

4. Choose the plateau, not the peak

Pick parameters from the middle of a stable profitable region, even if a neighbouring setting made more money.

5. Test on more than one market

A rule that only works on one symbol and one timeframe is more likely fitted than found. Try related symbols with no re-tuning.

6. Realistic costs

Spread and commission kill many overfit strategies on their own, because their edge per trade was tiny. Test with real ticks where you can — every tick vs real ticks.

7. Logic before numbers

If you cannot explain why a rule should work, the optimiser found it for you, and it probably will not keep working.

Where TradeSmithy fits

Parameter optimisation inside TradeSmithy is still in development — our homepage says so, and we would rather say it here too. What you can do today: wire any indicator period or threshold to a Global Parameter so it becomes an EA input, export the EA, and optimise it in MetaTrader's own Strategy Tester with the plateau-and-out-of-sample discipline above. How parameter ports work. Server backtests on Pro make it cheap to run your in-sample and out-of-sample periods as separate, recorded runs.

Start free to build a strategy with few, meaningful inputs, or see Pro for server backtests and the AI assistant. And be sceptical of anyone selling you a perfect curve — how to judge a bot honestly.

Frequently asked questions

What is curve fitting in trading?

Adjusting a strategy until it matches past data too closely, so that it describes that history's noise rather than a pattern that will repeat.

How do I know if my EA is overfitted?

Test it on data you did not use to build or tune it. A large drop in performance is the clearest sign.

How many parameters should an EA have?

As few as the logic needs. Each optimised parameter needs many trades to justify it.

Does optimisation always cause overfitting?

No. Optimisation over a few meaningful parameters, judged out of sample and chosen from a stable region, is sound practice.

Keep reading

← More from the TradeSmithy blog