Range & PivotPine Script v6

ta.pivothigh()Pivot High

Returns the price of a pivot high point. It returns NaN if there was no pivot high point.

TradingView language reference

Syntax

Syntax
ta.pivothigh(source, leftbars, rightbars) → series float

Arguments

ParameterTypeDescription
sourceseries int/floatSeries used to detect the pivot (often high).
leftbarsseries int/floatLeft-side pivot strength: number of bars used before the candidate.
rightbarsseries int/floatRight-side pivot strength: number of subsequent bars required for detection.

Returns

Price of the point or NaN.

Remarks

A pivot value is reported rightbars bars after the candidate. The example offsets the drawing back five bars, which does not make the value knowable five bars earlier. A result on the open confirmation bar can still change; wait for its close if required.

Code Examples

Pine Script v6 Example
//@version=6
indicator("pivothigh", overlay=true)
plot(ta.pivothigh(high, 5, 5), style=plot.style_circles, offset=-5)

Trading Applications

Identify swing high points for resistance levels

Build support/resistance detection systems

Create trendline drawing algorithms

Use for chart pattern recognition

Related Functions

Frequently Asked Questions

It detects a local high using the specified left and right strengths and returns the candidate value on the later detection bar. The two-argument overload uses high as its source.

They define the bars evaluated around a candidate. A larger right strength delays detection; it does not prove economic significance or eliminate false signals.

The function returns a value only when it detects a pivot and na otherwise. The plotted point may be shifted back to the candidate bar; trading logic must use the later detection time, not that historical drawing position.

Generate ta.pivothigh() Code with AI

Draft Pine Script using ta.pivothigh() with Pineify's AI Coding Agent, then review the arguments and test the result on your chart. Usage depends on your plan and available credits.