Returns the difference between the highest and lowest value of source over the last length bars.
ta.range is ta.highest(source, length) - ta.lowest(source, length). It measures the spread of a series over a rolling window, in the units of source.
The first value appears on bar number length, and an na in the window gives na.
Syntax
ta.range(source: series int/float, length: series int) -> series float
ta.range(source: series int, length: series int) -> series intArguments
| Name | Type | Default | Description |
|---|---|---|---|
| source | series int/ | required | The series whose highest and lowest values over length bars are subtracted. |
| length | series int | required | Number of bars in the window. A whole number of 1 or more. |
Returns
series float or series int: highest minus lowest value in the window.
Remarks
ta.range(close, n)uses closes only; useta.highest(high, n)-ta.lowest(low, n)for the full price range.
Example
//@version=6
indicator("Rolling range")
plot(ta.range(close, 20), "20-bar close range", color = color.purple)See also
Runs on Sidechair