Range & PivotPine Script v6

ta.range()Range

Returns the range (highest - lowest) of a series over a given number of bars.

Syntax

Syntax
ta.range(source, length) → series float

Arguments

ParameterTypeDescription
sourceseries int/floatSeries of values to process.
lengthseries intNumber of bars in the rolling window.

Returns

Difference between min and max values of source for length bars back.

Remarks

na values in the source series are ignored.

Code Examples

Pine Script v6 Example
//@version=6
indicator("ta.range")
plot(ta.range(close, 14))

Trading Applications

Measure price range for volatility assessment

Build range-based breakout systems

Calculate relative range for normalization

Use in custom channel indicators

Related Functions

Frequently Asked Questions

ta.range() returns max minus min of the source over the rolling length, summarizing how wide the window has been in the source units.

ta.range() applies to an arbitrary source over length bars. ATR is a smoothed average of true range (high/low/previous close), designed specifically for gap-aware volatility.

Compare current bar expansion to a short-term range baseline, e.g. breakout when price exceeds prior range multiple or when range compresses then expands.

Generate ta.range() Code with AI

Skip the manual coding. Use Pineify's AI Coding Agent to generate Pine Script code using ta.range() and other built-in functions instantly.