Optimization Settings
Parameters with optimize: true can be automatically tuned by the optimizer. The engine explores different combinations of parameter values across a grid to find the best-performing configuration.
Marking a Parameter for Optimization
ctx.param('fastLength', { type: 'int', label: 'Fast EMA', default: 9, min: 5, max: 50, step: 5, optimize: true, // <-- this makes it tunable });
When optimize: true, the optimizer uses min, max, and step to build a search grid:
| Setting | Purpose |
|---|---|
min | Lowest value to test |
max | Highest value to test |
step | Increment between tested values |
For the example above, the optimizer tests: 5, 10, 15, 20, 25, 30, 35, 40, 45, 50.
Grid Size Warning
The total number of combinations = product of each parameter's step count. Large grids take longer:
| Parameters | Steps Each | Total Combinations |
|---|---|---|
| 2 | 10 | 100 |
| 3 | 10 | 1,000 |
| 4 | 10 | 10,000 |
| 3 | 20 | 8,000 |
Keep the grid manageable. Prefer fewer parameters with wider steps for initial discovery, then narrow the ranges.
Fixed vs Optimized
Parameters without optimize: true (or with optimize: false) keep their default value throughout the optimization run. This is useful for structural settings that should not change:
// Fixed — always 'close' ctx.param('source', { type: 'string', default: 'close', options: ['open', 'high', 'low', 'close'], }); // Optimized — engine tests 5 through 50 ctx.param('period', { type: 'int', default: 14, min: 5, max: 50, step: 5, optimize: true, });
Step Size Tips
| Parameter | Recommended Step | Reasoning |
|---|---|---|
| EMA/SMA period (5–200) | 5–10 | Periods below 5 are noisy |
| RSI threshold (20–80) | 5 | Standard increments |
| ATR multiplier (1.0–5.0) | 0.5 | Meaningful granularity |
| Risk percentage (0.5–5.0) | 0.5 | Small change = big impact |
Interaction with Walk-Forward Analysis
During WFA, the optimizer runs independently on each training window. Parameters are re-optimized per window and validated on the out-of-sample segment. This tests whether the parameter surface is stable over time.
See Walk-Forward Analysis for details.