indicator · on price · open source
ATR Bands
Running…
Loading chart…
About
ATR Bands wrap a smoothed moving average with parallel ATR envelopes — a cleaner ride channel than Keltner that uses fixed ATR rather than the KC rolling formula.
- Outer rails are common stop and target levels.
- Slope of the mid line tells you the trend direction.
Source code
//@version=5
indicator("ATR Bands", overlay=true)
len = input.int(20, "EMA / ATR length", minval=2, maxval=200)
mult = input.float(2, "ATR multiplier", minval=0.1, maxval=10, step=0.1)
src = input.source("close", "Source")
m = ta.rma(src, len)
upper = m + ta.atr(len) * mult
lower = m - ta.atr(len) * mult
p_ATR_Mid = plot(m, "ATR Mid", color=color.orange, linewidth=2)
p_ATR_Upper = plot(upper, "ATR Upper", color=color.teal)
p_ATR_Lower = plot(lower, "ATR Lower", color=color.teal)
fill(p_ATR_Upper, p_ATR_Lower, color=color.new(color.teal, 90))
alertcondition(ta.crossover(close, upper), "Above upper", "Close crossed above the ATR upper band")
alertcondition(ta.crossunder(close, lower), "Below lower", "Close crossed below the ATR lower band")
No comments yet.
Sign in to comment.