Change
[[change]] measures the signed change in a series by subtracting the value observed length candles ago from its current value. The output is unbounded and expressed in the same unit as the source. A positive value indicates an increase over that interval, a negative value a decrease, and zero an unchanged value.
The source can be a price or the output of another indicator. Each result represents the source’s net movement between the two ends of the interval without describing the path taken in between. It is an arithmetic difference, not an absolute value or a percentage change.
Block declaration
A strategy can contain multiple [[change]] blocks. Each block outputs a single numeric series corresponding to the difference with a fixed lag.
Examples
Minimal setup
This block measures the change from one close to the next. Since length is omitted, the block uses the default length 1.
[[change]]
id = "change"Custom source and finding the optimal length
This block explores a range of values for length on the close series to identify the best-performing length.
[[change]]
id = "change"
source = "close"
length.start = 1
length.stop = 10
length.step = 1Variation of another indicator
This example applies change to an exponential moving average that has already been computed. It measures the variation of a smoothed signal instead of working directly on raw prices.
[[ma]]
id = "ema_fast"
type = "ema"
length = 20
[[change]]
id = "ema_slope"
source = "ema_fast"Parameters
| Parameter | Description |
|---|---|
idString Required | Unique identifier for the resulting series. |
sourceString or Array Optional | Input series used for the calculation. Accepted forms: source = "hl2" or source = ["close", "hl2"].Each value can be either a standard price source ( open, close, high, low, hl2, hlc3, ohlc4, hlcc4, volume) or the id of another indicator.Default value: "close" |
lengthInteger Optional | Lag in bars; must be ≥ 1 when provided. If length is omitted, the default value is 1.Usage: • Fixed: length = value• Grid search: – length.start = min_value– length.stop = max_value– length.step = value (optional, default 1) |
symbolString or Array Optional | Market symbol(s) used when source only consists of standard prices (open, close, high, low, hl2, hlc3, ohlc4, hlcc4, volume).If source mixes standard prices and indicator ids, symbol is applied only to combinations based on standard prices.If source contains only indicator ids, symbol is ignored.If symbol is omitted, the block inherits the symbol defined in [backtest].For symbol format, arrays, and alignment rules, see Exchanges, Symbols and Timeframes. |
timeframeString or Array Optional | Timeframe on which this indicator is computed. If timeframe is omitted, the computation uses the grid’s main timeframe defined in [backtest].For accepted formats and timeframe alignment rules, see Exchanges, Symbols and Timeframes. |
Available variables
Use the block id directly in your expressions.
Assuming id = "change":
| Variable | Description |
|---|---|
change or change[0]Decimal | Current difference (e.g., close - close[1]). First length samples are NaN. |
change[n]Decimal | Value n bars ago (change[1] is the previous bar). |
change.lengthDecimal | Effective lag used during the current combination. |
change.sourceString | Actual source (close, high, another indicator). |
change.symbolString | Symbol used by this block. |
change.timeframeString | Timeframe used for the computation. |