pivothigh
Detects pivot high (local peak) points in a data series
pivothigh(source, leftbars, rightbars)
Parameters
Pivot High - pivothigh(source, leftbars, rightbars)
Detects local peaks where source is higher than both surrounding bars.
- source (field): Data series (commonly high)
- leftbars (int): Bars before pivot that must be lower
- rightbars (int): Bars after pivot that must be lower
Formula
Returns source value when:
source > all leftbars preceding values
AND source > all rightbars following values
Otherwise returns NULL
Examples
// detect swing high with 2-bar confirmation
pivothigh(high, 2, 2) != null;
// swing high above 200 (resistance breakout)
x = pivothigh(high, 5, 5); x > 200;
// any detected swing high on close
pivothigh(close, 3, 3) != null;
Returns
Source value at pivot or NULL. Most bars return NULL.
Standalone usage (e.g.,
pivothigh(high, 2, 2);) automatically filters to non-NULL values. Use == null to find bars without pivots, or != null for explicit filtering.