TradeLabs AILearn

Parameter Optimization

Choosing strategy parameters by optimisation risks overfitting. Learn grid and random search, robustness surfaces, walk forward optimisation and sensible defaults.

Intermediate3 min readUpdated 3 Oct 2026
Markdown
Lesson 14 of 38

Almost every trading strategy has parameters: lookback periods, thresholds, stop distances, position size rules. Choosing them by testing many values and picking the best is called parameter optimisation. It is a natural step, but it is also where most overfitting happens. The goal is not to find the single best historical setting, but to find settings that are likely to work reasonably well in the future. This lesson applies the general ideas from Optimization specifically to trading strategy design.

The problem with "best" parameters#

When you test many parameter combinations on the same data, the best one is partly selected for luck. Its backtest performance is biased upward, and the more combinations you test, the larger the bias. See P-Hacking and Multiple Testing.

Search methods#

MethodDescriptionNotes
Grid searchTest every combination on a gridSimple; expensive with many parameters
Random searchTest random combinationsOften as good as grid search with fewer tests
Bayesian optimisationUses past results to choose promising next testsEfficient for expensive backtests
Genetic algorithmsEvolve parameter sets through selection and mutationPowerful, high overfitting risk

Look at the whole surface#

Instead of picking the top result, plot performance across parameter values.

Principles for robust parameters#

  1. Fewer parameters: each one adds a dimension for overfitting.
  2. Coarse grids: test values that differ meaningfully (20, 50, 100 days), not every integer.
  3. Prefer plateaus over peaks.
  4. Use sensible defaults grounded in reasoning, such as one month or one year lookbacks.
  5. Check neighbours: a good setting should have good neighbours.
  6. Combine several settings: averaging signals across parameter values reduces dependence on any one. See Combining Signals.
  7. Validate out of sample and with walk forward tests. See Walk-Forward Analysis.

Walk forward optimisation#

Optimise on a rolling past window, trade the chosen parameters on the next period, then re optimise. The stitched out of sample results show how the optimisation process itself performs. If chosen parameters jump around wildly between windows, the optimisation is likely fitting noise.

Objective functions#

What you optimise matters:

ObjectiveRisk
Total returnEncourages excessive risk and leverage
Sharpe ratioCan favour negatively skewed strategies. See Skewness and Kurtosis
Return to drawdownSensitive to one worst period
Multiple criteriaMore balanced; harder to compare

Optimise for robustness and risk adjusted returns, not just profit.

Parameter count vs data#

A rough guide: the more trades and the longer the history relative to the number of parameters, the safer the optimisation. A strategy with 10 parameters and 80 trades is very likely overfit; one with 2 parameters and 2,000 trades much less so.

Frequently asked questions#

What is parameter optimisation in trading?#

Testing different values for a strategy's settings, such as lookback periods or thresholds, to choose those expected to perform well.

How do I avoid overfitting when optimising parameters?#

Use few parameters, coarse grids and broad plateaus of good performance, check neighbouring values, and validate with walk forward and out of sample tests.

Should I always use the best performing parameters?#

No. The best historical values are often lucky; settings in the middle of a stable region of good results are usually more reliable.

Next, learn to test how fragile a strategy is in Robustness and Stress Testing.

Check your understanding

3 quick questions on this lesson. Get them all right to finish it.

Turn on JavaScript to take the quiz.

Finished this lesson?Sign in to save your progress across devices.
Next lessonRobustness and Stress TestingRobustness tests check whether a strategy survives changes in parameters, markets, costs and conditions. Learn the main tests and how to read the results.

Mentioned in