What Is Strategy Optimization and Why It Matters
Strategy optimization searches parameter values against an objective using backtests. How it works, what to optimise for, how many parameters is too many, and how to keep it honest.
Almost every strategy has numbers that are not obvious: the length of a moving average, the width of a stop, the hour a session starts. Optimisation is the systematic search for values of those parameters that make the strategy work well on historical data, judged by an objective you define.
Done carefully, it adapts a sound idea to a market. Done carelessly, it is the fastest way to build a strategy that only works in the past.
The four parts of an optimisation
- Parameters to search - for example, breakout lookback 10-50 bars, ATR stop multiple 1.0-3.0.
- Ranges and steps - which values are tested. Step size decides how fine the search is: lookback in steps of 5, ATR multiple in steps of 0.25.
- Objective (fitness) - how each parameter set is scored: profit factor, return over drawdown, Sharpe ratio, or a combination.
- Search method - testing every combination (grid) or a smarter search such as a genetic algorithm.
Each combination is one backtest, often called a pass. The optimiser ranks passes by fitness.
The size of the search space
Combinations multiply quickly:
| Parameters | Values each | Combinations |
|---|---|---|
| 2 | 10 | 100 |
| 3 | 10 | 1,000 |
| 5 | 10 | 100,000 |
Two problems grow with that number. The search becomes slow, and - more important - the best result becomes less trustworthy. Among 100,000 random variations, some will look excellent on any history purely by chance.
Choosing the objective
The objective decides what “best” means, and the optimiser will exploit it ruthlessly.
- Net profit alone tends to select the largest position sizes and riskiest settings.
- Profit factor alone tends to select settings with very few trades.
- Win rate alone tends to select tiny targets and wide stops.
More balanced choices:
- Return / maximum drawdown - reward relative to pain.
- Expectancy per trade with a minimum trade count - edge with enough evidence.
- Several criteria together - for example, maximise profit factor and minimise equity drawdown, discarding passes with fewer than 100 trades.
Platforms combine criteria in different ways. cTrader, for example, lets you add several standard criteria to maximise or minimise and combines them into one fitness value, or lets you write a custom fitness function in the cBot’s code.
What optimisation is good for
- Understanding sensitivity. Which parameters matter, and which barely change the result.
- Finding robust regions. Areas where many neighbouring settings work, suggesting a real effect.
- Adapting to an instrument. A breakout lookback that suits gold’s volatility may not suit EURUSD.
- Rejecting ideas. If no reasonable setting works, the idea is probably weak.
How optimisation goes wrong
- Too many parameters for the amount of data.
- Fine steps that let the optimiser pick isolated lucky values.
- No out-of-sample test, so the reported result is entirely in-sample.
- Repeated rounds of optimisation on the same data, each adding a filter.
The result is over-optimisation: beautiful backtests, disappointing live trading.
A sound optimisation routine
- Fix the logic first. Optimisation tunes a working idea; it does not create one.
- Choose 2-3 key parameters and keep the others at sensible defaults.
- Use coarse steps first. Refine only if a stable region appears.
- Optimise on the development period only. Keep recent data aside.
- Inspect the landscape, not just the top row. Look for plateaus in a heatmap or in neighbouring passes - see parameter stability analysis.
- Pick from the middle of a stable region, not the single highest pass.
- Validate on out-of-sample data or with walk-forward analysis.
- Stress the chosen settings with higher costs and Monte Carlo reshuffling.
A short example
A trend-pullback strategy on gold has three parameters: trend EMA (50-200), pullback depth in ATR (0.5-2.0) and stop multiple (1.0-3.0). A coarse grid gives 4 × 4 × 5 = 80 passes.
The top pass shows profit factor 2.4 with 60 trades - but its neighbours drop to 1.1. A broader area around EMA 100-150, pullback 1.0-1.5 and stop 2.0-2.5 shows profit factors of 1.5-1.7 with 150-200 trades. The second area is the better choice: more trades, similar results across neighbours, and less dependence on one exact value.
Key takeaways
- Optimisation searches parameter values against an objective you define.
- The number of combinations and the choice of objective decide how trustworthy the result is.
- Prefer few parameters, coarse steps and balanced, multi-criteria objectives.
- Choose stable regions, then confirm on data the optimiser never saw.
FAQ
Is optimisation the same as curve fitting?
No, but it easily becomes curve fitting. Optimisation is a search for settings that suit the market's behaviour. It turns into curve fitting when you search too many parameters on too little data and believe the best result without testing it on new data.
How many parameters should I optimise?
As few as possible - often two or three that clearly control the strategy's behaviour. Every extra parameter multiplies the number of combinations and the chance of finding a lucky one.
What should I optimise for?
A balance of reward and risk with a minimum sample size, for example profit factor or expectancy together with a cap on equity drawdown and a minimum number of trades. Optimising for net profit alone usually selects the riskiest settings.
Sources and further reading
- cTrader Help: Optimise a cBot - help.ctrader.com
- cTrader Help: Custom fitness functions - help.ctrader.com
- Bailey et al.: The Probability of Backtest Overfitting - papers.ssrn.com