Optimised constants
The constant block defines a named numeric value whose values Whale‑E varies during grid search. It is primarily used to express thresholds or constants (for example, overbought and oversold levels).
Unlike an indicator block, a constant does not produce a time series and is not tied to any symbol or timeframe. It exposes a named variable (its id) that can be referenced in conditional blocks and expressions.
Defining a constant in TOML
A constant block is declared with an identifier (id) and a numeric interval delimited by start and stop. The step is optional; when provided, Whale‑E tests start, start + step, start + 2 × step, … up to stop.
Integer example:
[[constant]]
id = "overbought"
start = 70
stop = 76
step = 2Decimal example:
[[constant]]
id = "take_profit_pct"
start = 0.5
stop = 1.0
step = 0.1Using a constant in strategy rules
A constant is referenced by its id, like any strategy variable. You can use it inside conditional blocks:
- In a
positionblock to compare a series against a threshold:
[[position]]
id = "k_above_oversold"
position = "above"
reference = "stoch_k"
comparison = "oversold"- In a
conditionblock within a logical expression:
[[condition]]
id = "buy_condition"
condition = "rsi > overbought and k < oversold"You can also add a constraint on combinations to eliminate incoherent cases and reduce the number of backtests. For example, you can require the oversold threshold to remain strictly lower than the overbought threshold:
[constraints]
condition = "oversold < overbought"For details on these constraints and their impact on the search space, see the dedicated page: Hyperparameter Combinations.