Skip to content

Guides

Optimize without overfitting

Find settings that work, not settings that happened to work once.

Trading on margin can lose you more than you put in. Past results, including backtests, do not predict future results. Cloud9Trader provides tools and education, not financial advice. Read the full risk warning.

Do this: Decide on two periods before you start: one to optimize on, and a later one you will not look at until the end. For example, optimize on 2023 and test on the first half of 2024.

Do this: Open the algorithm’s Optimize tab and select New Optimization. Give each external a range, such as 3 to 10 for fast and 15 to 50 for slow. Choose Exhaustive for a few combinations, or Genetic Algorithm for many.

You should see: A list of backtests, one per combination, that you can sort by profit or drawdown.

Look for a region of settings that all do reasonably well, and pick from the middle of it. A single setting that does far better than its neighbours is usually luck.

Do this: Run one backtest with your chosen settings on the second period.

If it does much worse there, the settings fit the past rather than the market. Go back to fewer externals or wider ranges, not to more tuning on the same data.

How many externals should I optimize? As few as possible. Each one multiplies the combinations and the chance of a lucky fit.

What does it cost? An exhaustive optimization costs one backtest’s compute units for every combination. See Plans and credits.