Lag (N bars)
The value N bars ago — series.shift(n)
When to use: Cross-bar conditions: comparing the current value against the past (momentum accelerating/fading), building multi-bar persistence (e.g. an EMA stack holding for 4 straight bars = AND of lag 0-3), or preventing self-inclusion in rolling_max/min
Ports
in-value— The source seriesout-value— The same value, shifted N bars
Params
periods— Number of bars to look back
Used in these recipes
- Breakout — New High + ADX Filter