Functions
ta.pivothigh(source, leftBars, rightBars)
Returns the pivot high value if the bar at rightBars ago is higher than all leftBars bars before it and all rightBars bars after it. Returns NaN otherwise.
ta.pivotlow(source, leftBars, rightBars)
Returns the pivot low value under the same symmetric condition.
The lag
Parameters
(offset?) => number | null
required
Source function. Typically
ctx.high for pivot highs, ctx.low for pivot lows.number
required
Number of bars to the left that must be lower (for pivothigh) or higher (for pivotlow).
number
required
Number of bars to the right that must be lower/higher. This is also the lag: the pivot result is known
rightBars after the candidate bar.Basic example
Choosing left/right bars
Asymmetric values are allowed (
pivothigh(ctx.high, 3, 8)) but less common.
Related pages
Support/resistance example
Full indicator using pivothigh/pivotlow + Line entities.
Aggregators
ta.highest/lowest for simpler range detection.
NaN handling
na() check before using pivot results.