Skip to content
Algo Trade Analytics Docs

ta.atr() - Pine Script Function

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])).

ta.atr(length) → series float
NameTypeDescription
lengthsimple intLength (number of bars back).

Average true range.

  • na values in the source series are ignored; the function calculates on the length quantity of non-na values.
//@version=6
indicator("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))