Average True Range
Average size of the bar range including gaps.
indicator("Average True Range", shorttitle="ATR")
len = input.int(14, "Length", minval=1)
smoothing = input.string("RMA", "Smoothing", options=["RMA", "SMA", "EMA", "WMA"])
ma(src, n) =>
switch smoothing
"SMA" => ta.sma(src, n)
"EMA" => ta.ema(src, n)
"WMA" => ta.wma(src, n)
=> ta.rma(src, n)
plot(ma(ta.tr(true), len), "ATR", linewidth=2)