# Parameter Optimization

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

Source: https://learn.tradelabsai.com/research/parameter-optimization/  
Track: Research and Backtesting · Level: Intermediate · Updated: 2026-10-03  
Publisher: TradeLabs AI (https://tradelabsai.com). Education, not financial advice.  
Cite as: TradeLabs Learn, "Parameter Optimization", https://learn.tradelabsai.com/research/parameter-optimization/

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](https://learn.tradelabsai.com/math/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](https://learn.tradelabsai.com/research/p-hacking-and-multiple-testing/).

## Search methods

| Method | Description | Notes |
|---|---|---|
| Grid search | Test every combination on a grid | Simple; expensive with many parameters |
| Random search | Test random combinations | Often as good as grid search with fewer tests |
| Bayesian optimisation | Uses past results to choose promising next tests | Efficient for expensive backtests |
| Genetic algorithms | Evolve parameter sets through selection and mutation | Powerful, high overfitting risk |

## Look at the whole surface

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

**Example: Peak vs plateau**
A trader optimises a breakout strategy's lookback (10 to 100 days) and stop (1 to 4 ATR). A heatmap of Sharpe ratios shows one bright spot at a 37 day lookback and 2.3 ATR stop (Sharpe 1.6), surrounded by values near 0.3. Elsewhere, a broad region from 50 to 80 days and 2.5 to 3.5 ATR shows Sharpe ratios consistently around 0.9. The broad plateau is far more trustworthy than the isolated peak, because small changes in market behaviour are less likely to destroy it. The trader chooses settings in the middle of the plateau. See [Robustness and Stress Testing](https://learn.tradelabsai.com/research/robustness-and-stress-testing/).

## 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](https://learn.tradelabsai.com/research/combining-signals/).
7. **Validate out of sample and with walk forward tests.** See [Walk-Forward Analysis](https://learn.tradelabsai.com/research/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:

| Objective | Risk |
|---|---|
| Total return | Encourages excessive risk and leverage |
| Sharpe ratio | Can favour negatively skewed strategies. See [Skewness and Kurtosis](https://learn.tradelabsai.com/math/skewness-and-kurtosis/) |
| Return to drawdown | Sensitive to one worst period |
| Multiple criteria | More 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](https://learn.tradelabsai.com/research/robustness-and-stress-testing/).

## Continue learning

- Next lesson: [Robustness and Stress Testing](https://learn.tradelabsai.com/research/robustness-and-stress-testing/)
- Previous lesson: [Monte Carlo Simulation](https://learn.tradelabsai.com/research/monte-carlo-simulation/)
- Related: [Monte Carlo Simulation](https://learn.tradelabsai.com/research/monte-carlo-simulation/): Monte Carlo simulation generates thousands of possible outcomes to show the range of results. Learn trade resampling, drawdown estimates and the limits.
- Related: [Optimization](https://learn.tradelabsai.com/math/optimization/): Optimisation finds inputs that maximise or minimise an objective, from portfolio weights to strategy settings. Learn the methods and how to avoid overfitting.
- Related: [Overfitting and Curve Fitting](https://learn.tradelabsai.com/research/overfitting-and-curve-fitting/): Overfitting means a strategy fits noise instead of a real pattern. Learn the warning signs, why it happens, how to measure it and practical ways to avoid it.
- Related: [Walk-Forward Analysis](https://learn.tradelabsai.com/research/walk-forward-analysis/): Walk forward analysis repeatedly optimises a strategy on past data and tests it on the next period. Learn how it works, window choices, efficiency ratios and limits.
- Related: [Robustness and Stress Testing](https://learn.tradelabsai.com/research/robustness-and-stress-testing/): Robustness tests check whether a strategy survives changes in parameters, markets, costs and conditions. Learn the main tests and how to read the results.
- Related: [P-Hacking and Multiple Testing](https://learn.tradelabsai.com/research/p-hacking-and-multiple-testing/): Testing many strategy variations guarantees some look good by chance. Learn how p hacking happens, how to adjust for multiple tests and the deflated Sharpe ratio.
