DocsParameters

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:

SettingPurpose
minLowest value to test
maxHighest value to test
stepIncrement 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:

ParametersSteps EachTotal Combinations
210100
3101,000
41010,000
3208,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

ParameterRecommended StepReasoning
EMA/SMA period (5–200)5–10Periods below 5 are noisy
RSI threshold (20–80)5Standard increments
ATR multiplier (1.0–5.0)0.5Meaningful granularity
Risk percentage (0.5–5.0)0.5Small 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.

optimizationoptimizegridrangeminmaxsteptuning