Title here
Summary here
[[constant]] defines a named numeric value used as a reusable threshold or constant in your rules. Its value changes during grid search without creating a time series or depending on a symbol or timeframe.
A strategy can contain multiple [[constant]] blocks. Each block specifies an identifier and a value interval. One backtest is run for each value in the interval.
[[constant]]
id = "overbought"
start = 70
stop = 76
step = 2[[constant]]
id = "take_profit_pct"
start = 0.5
stop = 1.0
step = 0.1Reference a constant by its id, like a variable:
[[position]]
id = "k_above_oversold"
position = "above"
reference = "stoch_k"
comparison = "oversold" # uses the "oversold" constant[[condition]]
id = "buy_condition"
condition = "rsi > overbought and k < oversold"You can also constrain the search space globally to discard incoherent combinations (see the “Hyperparameter Combinations” page):
[constraints]
condition = "oversold < overbought"| Parameter | Description |
|---|---|
idText Required | Unique name of the exposed constant. |
startDecimal or Integer Required | Start bound of the interval. |
stopDecimal or Integer Required | End bound of the interval. |
stepDecimal or Integer Optional | Increment between successive values. |
The Constant block exposes a scalar variable accessible via its id:
| Variable | Description |
|---|---|
<id>Decimal | Current value of the constant, usable in expressions (conditions, positions, etc.). |
ids must be unique within the strategy.[[constant]] does not feed indicator internal parameters (e.g., length, offset). Indicator parameter ranges are defined directly in the corresponding indicator block.