Shift
The Shift node slides a time series along the time axis by a fixed number of periods. A positive shift delays values (they appear later), a negative shift advances them (they appear earlier). Array length and timestamp alignment are preserved; vacated positions are filled with null.
Formula
Positive shift (n > 0) — lag / delay:
result[i] = values[i − n] for i ≥ n
result[i] = null for i < n
Negative shift (n < 0) — lead / advance:
result[i] = values[i + |n|] for i < len − |n|
result[i] = null for i ≥ len − |n|
n = 0 returns an exact copy of the input. The output array always has the same length as the input.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| n | number | 0 | Number of periods to shift. Positive = lag (values move right), negative = lead (values move left). Integer only. |
Inputs & Outputs
| Port | Type | Description |
|---|---|---|
| Input | ||
| input | (number | null)[] | Any numeric series with matching timestamps. |
| Outputs | ||
| values | (number | null)[] | Shifted series. Same length as input; null fills vacated positions. |
| timestamps | number[] | Original timestamps — unchanged. Timestamps represent the current bar, not the source bar. |
Use Cases
Price change (momentum)
Shift the close series by n=1, then subtract the shifted version from the unshifted close using a Math Subtract node. The result is the bar-over-bar price change — equivalent to a 1-period momentum.
Crossover detection with lagged reference
Shift an indicator series by 1 and feed both the current and lagged series into a Crossover logic node. This gives you a clean one-bar crossover detection without any additional processing.
Lookahead simulation (backtesting)
Use a negative shift (e.g. n = −1) to simulate next-bar open prices alongside current signals. This helps validate that your strategy is not accidentally using future data in backtests.