OPEN-SOURCE SCRIPT

200 EMA with ATR Bands

158
//version=6
indicator("200 EMA with ATR Bands", overlay=true)

// === Inputs ===
emaLength = input.int(200, "EMA Length", minval=1)
atrLength = input.int(14, "ATR Length", minval=1)
atrMult = input.float(1.5, "ATR Multiplier", step=0.1, minval=0.1)
emaColor = input.color(color.yellow, "EMA Color")
bandColor = input.color(color.new(color.teal, 80), "Band Fill Color")

// === Calculations ===
ema200 = ta.ema(close, emaLength)
atrVal = ta.atr(atrLength)

// Bands based on ATR
upperBand = ema200 + atrVal * atrMult
lowerBand = ema200 - atrVal * atrMult

// === Plot ===
plot(ema200, title="200 EMA", color=emaColor, linewidth=2)
pUpper = plot(upperBand, title="Upper ATR Band", color=color.new(color.teal, 0))
pLower = plot(lowerBand, title="Lower ATR Band", color=color.new(color.teal, 0))

// Fill the band region
fill(pUpper, pLower, color=bandColor, title="ATR Band Fill")

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.