ta.atr() - Pine Script Function
ta.atr()
Section titled “ta.atr()”Overview
Section titled “Overview”Function atr (average true range) returns the RMA of true range. True range is max(high - low, abs(high - close[1]), abs(low - close[1])).
Syntax
Section titled “Syntax”ta.atr(length) → series floatParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| length | simple int | Length (number of bars back). |
Returns
Section titled “Returns”Average true range.
Remarks
Section titled “Remarks”- na values in the source series are ignored; the function calculates on the length quantity of non-na values.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("ta.atr")plot(ta.atr(14))//the same on pinepine_atr(length) => trueRange = na(high[1])? high-low : math.max(math.max(high - low, math.abs(high - close[1])), math.abs(low - close[1])) //true range can be also calculated with ta.tr(true)ta.rma(trueRange, length)plot(pine_atr(14))