Home›Learn›Expert Advisors›How to Optimise an EA

How to Optimise an EA

A careful walk through the MT4 Strategy Tester optimiser, the metric to rank by, and the over-fitting trap that makes backtests lie.

Expert Advisors6 minUpdated 14 Aug 2026
How to Optimise an EA

The Strategy Tester optimiser runs your EA across hundreds or thousands of parameter combinations and tells you which set scored best on past data. Used with care, it narrows a sensible range of settings. Used carelessly, it hands you the single luckiest combination in the sample and calls it a strategy. The whole skill is telling those two outcomes apart.

What the optimiser does

In MT4's Strategy Tester you tick Optimisation, then in the Inputs tab you give each parameter a Start, Step and Stop. The tester runs a backtest for every combination in that grid and ranks the results by one metric. Optimise three parameters with ten values each and that is a thousand backtests — at least one of which will look extraordinary by chance alone.

A careful walkthrough

  1. Optimise few parameters at once. Two or three that matter, not every field. More dimensions means more ways to fit noise.
  2. Rank by the right metric. Net profit alone rewards reckless sets; read profit factor and maximum drawdown beside the profit, or use a measure that already accounts for risk.
  3. Use good data. "Every tick" modelling and quality history, or the result describes a market that never existed.
  4. Set honest ranges and steps — wide enough to learn something, coarse enough that you are not fitting to the third decimal.
  5. Read the whole surface rather than the top row alone.

Choose a plateau, not a peak

This is the part most people skip. Sort the results and you see a top score, often a sharp spike where 14 works brilliantly and 13 and 15 are mediocre. That spike is fragile; the live market will not land on exactly 14. Look instead for a broad plateau where a whole neighbourhood of values all did reasonably well. A setting surrounded by other good settings is far likelier to hold up than a lone peak.

The best row in an optimisation is usually the luckiest, not the best. If moving one parameter a single step either way collapses the result, you have found an accident, not an edge.

The over-fitting trap

Every extra parameter, every finer step, every re-run tuned to lift last year's curve pulls you towards curve-fitting: a set that describes the past perfectly and predicts nothing. The optimiser cannot warn you, because a fitted set is exactly what you asked it to find.

Validate out of sample

Optimise on one slice of history, then test the chosen set on a later slice it never saw. Better, run a walk-forward analysis that repeats this rolling forward in steps. If the set only works on the data it was tuned on, it is not a strategy.

A worked example

An optimiser hands you a set showing £9,200 profit on two years of GBPUSD with a tidy curve. Run it forward on the next six months it never saw and you get £180, then a £700 drawdown. The backtest was real; it was also fitted. Had you picked the plateau set — £6,100 on the same two years, but stable one step either side — the forward test would more likely have survived.

The Karnek note

Karnek shows the live results of whatever set you finally choose, read-only from your terminal, so you can hold the real account against the backtest that sold you on it. It never optimises, changes a parameter or places a trade. Seeing the two side by side is usually where the over-fitting shows itself.

See it in Karnek: monitor every EA live, with an alert the instant one stops.

More in Expert Advisors →

Written and reviewed by the Karnek Research team. Last updated August 2026.

Educational content only - not financial advice. Past performance does not predict future results. Trading carries significant risk.