Optimization
Find which settings made the difference, and whether they are a fluke.
An optimization runs many backtests of one algorithm version, each with different values for its externals, and shows them side by side. Use it after a plain backtest shows an idea is worth tuning.
What it does
Section titled “What it does”- Searches over the externals your algorithm declares, in one of two ways:
- Exhaustive runs every combination on a grid you define: for each external, a range and a number of values from 2 to 10.
- Genetic Algorithm starts from random settings within your ranges, keeps the best, breeds and mutates them into a new generation, and stops when results stop improving or a limit is reached. It can search ranges too large to try in full.
- Shows every run as it completes:
- Backtest Runs: each run’s profit and maximum drawdown, in order.
- Externals / Profit: profit against each external’s value, so you can see which settings matter.
- Backtests: a table of every run with its externals, position count, profit and drawdown. Open any run to see its full backtest result.
How it works
Section titled “How it works”- On the algorithm’s Optimize tab, select New Optimization.
- Choose the version, instrument, interval, dates and balance, and choose the strategy: Exhaustive or Genetic Algorithm (the default).
- Set a range for each external. For Genetic Algorithm, review its settings, such as when to stop.
- Select OK and watch the charts fill in.
Look for a plateau: a region of settings that all did reasonably well. A single run far better than its neighbours is more likely to be luck. See Overfitting and optimization.
Limits
Section titled “Limits”- A run that gets no answer within 75 minutes is marked Failed, so the optimization can still finish.
- Optimizations run on minute data only. Re-run the settings you choose as a backtest on every tick.
- Only numeric externals can be optimized, and a version with no externals cannot be optimized.
- A genetic search stops after at most 10,000 backtests (1,000 by default).
- In the Backtests table, Return / Drawdown is the return divided by the maximum drawdown. It is not a profit factor (gross gains divided by gross losses).
- Cloud9Trader does not split in-sample and out-of-sample periods for you. Keep a later period back and test on it yourself.
An exhaustive optimization uses backtest compute units for every run: one unit per 30 days tested, multiplied by the number of combinations. The window shows the total before you start, and OK stays disabled if you do not have enough.
Read next
Section titled “Read next”- Backtesting: the engine every run uses.
- Overfitting and optimization: choosing settings without fooling yourself.