Pro Lab
Strategy optimizer: test every setting of a strategy
The strategy optimizer runs one of your AlertaScript strategies with every combination of the inputs you choose. It shows which settings worked, which held up on bars they had never seen and how much of the result could be luck. It is a Pro Lab tool, part of the Pro and Elite plans.
Running an optimization
- On a computer, press Pro Lab on the right-hand toolbar; on a phone, open the analysis centre from the chart's bottom bar and choose Pro Lab. Then choose Strategy optimizer.
- Pick a strategy from My scripts or paste a strategy's code; pasted code is not saved. Choose the symbol, the timeframe (15 minutes, 1 hour, 4 hours or 1 day) and 1,000, 2,000, 3,000 or 5,000 bars.
- Choose up to three number inputs and give each a start, an end and a step. One run tests up to 100 combinations.
- Keep the walk-forward check on if you want it and press Run optimization. The map fills in as the backtests finish, and stopping keeps what is done.
Reading the results
- Each cell of the heat map is one backtest, coloured by the measure you choose: net profit, profit factor, maximum drawdown, return to drawdown, Sharpe, Sortino, win rate or number of trades.
- A setting whose neighbours also do well (a plateau) is more trustworthy than a single cell that shines alone, which is marked as a likely overfit. Settings with fewer trades than your minimum are hatched and left out.
- The walk-forward check optimizes on the first 70% of the bars and runs the best 3 settings on the last 30%. Efficiency compares their profit rate there with the first part; above 50% usually counts as robust.
- Monte Carlo replays the closed trades of the setting you select 1,000 times, resampled or in a shuffled order, and shows the range of drawdowns and final returns. It needs at least 5 closed trades.
Good to know
- Only number inputs can be varied, so the strategy needs at least one.
- When the best setting sits on the edge of a range you tested, widen the range to see what lies beyond it.
- Past results do not promise future ones. The plateau and the walk-forward check help you avoid settings that only fit the past.