Optimization

Best Practices for Robust Algorithmic Optimization

A practical checklist for optimising trading algorithms without fooling yourself: preparation, search design, fitness, stability, validation, stress tests and documentation.

By AlgoXP3 min readUpdated

Optimization heatmap of two parameters with a stable region highlighted and a lone peak

Optimisation is where most trading strategies are made - and where most of them are quietly ruined. The difference between a robust result and a curve-fitted one rarely comes from the software. It comes from the process around it. This checklist summarises the practices that consistently produce strategies that survive contact with live markets.

Before you optimise

1. Start from a working idea. The strategy should show some edge with sensible default parameters. Optimisation tunes an idea; it cannot create one.

2. Write a test plan. Parameters to optimise, ranges, steps, objective, data split and success criteria - decided before the first run.

3. Split the data. Development, validation and a final out-of-sample period, or a walk-forward schedule. The most recent data stays untouched.

4. Use realistic costs. Optimising without spread and commission selects settings that trade too often.

5. Optimise few parameters. Two or three that clearly drive behaviour. Fix the rest at reasonable defaults.

6. Use scale-free parameters. ATR multiples and percentages travel better across markets and years than fixed points.

7. Coarse steps first. Wide ranges and coarse steps reveal the landscape; fine steps invite the optimiser to find lucky spikes.

8. Choose the method for the job. A grid shows the full landscape for small searches; a genetic algorithm explores large ones faster. Use a genetic search to find regions, a grid to examine them.

Choosing the objective

9. Optimise risk-adjusted performance. Return over drawdown, expectancy per trade or a combination of criteria - not raw net profit.

10. Require enough trades. Reject passes below a minimum trade count. In cTrader this is easy with a custom fitness function that returns zero for small samples.

11. Watch equity, not just balance. For strategies that hold losing positions, include equity drawdown in the objective.

Selecting results

12. Look at the landscape. Sort passes by parameter, build heatmaps, and find plateaus. See parameter stability analysis.

13. Choose from the centre of a stable region, not the top row of the table.

14. Check sensitivity. Moving each parameter ±20% should degrade results gradually.

15. Prefer simpler candidates. When two candidates perform similarly, the one with fewer rules and parameters is usually more robust.

Validating

16. Decide on unseen data. Run the chosen settings once on the final out-of-sample period. Do not iterate on it.

17. Use walk-forward analysis for strategies that will be re-optimised over time.

18. Test on related markets and timeframes. A general idea should show some edge beyond its home market - see multi-market optimisation.

Stress testing

19. Raise costs by 50-100%.

20. Delay entries by one bar.

21. Remove the best trades and look again.

22. Run Monte Carlo reshuffling and resampling to get drawdown percentiles - see Monte Carlo simulation.

23. Confirm on tick data if you explored on bars.

Documenting

24. Keep a research log. Every run: date, version, data, parameters, objective, results, decision.

25. Count the trials. The number of variants tested is part of the evidence. Many trials require stronger out-of-sample confirmation.

26. Record the stable region, not just the chosen value. It guides future adjustments.

After going live

27. Forward test first. A demo or small-size period confirms execution and behaviour - see why forward testing matters.

28. Re-optimise on schedule, using the same procedure that was validated, not in reaction to a drawdown.

29. Define review triggers in advance, for example a drawdown beyond the Monte Carlo 95th percentile.

A compact version

If you only remember five things:

  1. Few parameters, coarse steps.
  2. Risk-adjusted objective with a minimum trade count.
  3. Choose plateaus, not peaks.
  4. Decide on data the optimiser never saw.
  5. Stress-test before trusting.

Key takeaways

  • Robust optimisation is a process: plan, search, select, validate, stress, document.
  • Most failures come from too much freedom, too little data and decisions on in-sample results.
  • Out-of-sample data and walk-forward analysis are how you measure success.
  • A modest, stable result is worth more than a spectacular, fragile one.

FAQ

What is the most important optimisation rule?

Keep data the optimiser never sees and make the final decision there. Everything else reduces the risk of overfitting; untouched out-of-sample data is how you measure whether you succeeded.

How often should a live strategy be re-optimised?

On a fixed schedule that you tested, for example every six months in a walk-forward analysis - not whenever results disappoint. Re-optimising after every losing period is a way of chasing noise.

Should I optimise on tick data?

Use the data resolution the strategy needs. Bar data is much faster for exploration; final candidates should be confirmed on tick data, especially if stops are tight or entries happen inside bars.

Sources and further reading

  1. Bailey, Borwein, López de Prado, Zhu: The Probability of Backtest Overfitting - papers.ssrn.com
  2. cTrader Help: Optimise a cBot - help.ctrader.com
  3. cTrader Help: Custom fitness functions - help.ctrader.com