Yes sir, you can definitely create an ATR indicator in Pine Script.
ATR, or Average True Range, is a volatility indicator that measures the average range of price movement over a selected period.
The True Range considers the current High-Low range as well as the previous candle’s Close.
You can create a basic ATR indicator using:
//@version=6
indicator("Custom ATR", overlay=false)
atrLength = input.int(14, "ATR Length")
trueRange = ta.tr(true)
atrValue = ta.rma(trueRange, atrLength)
plot(atrValue, "ATR", color = color.red)
-> ta.tr(true) calculates the True Range.
-> ta.rma() calculates the moving average of the True Range, which gives us the ATR.
-> The default ATR length is 14, but users can change it from the indicator settings.
=> A higher ATR value generally indicates higher market volatility, while a lower ATR value indicates lower volatility.
So thatβs how you can create a basic ATR indicator from scratch in Pine Script.