Pine Script (TradingView)
This is a TradingView Pine Script example for this indicator. Paste it into the TradingView Pine Editor, add it to your chart, and adjust inputs for your market and timeframe.
//@version=6
indicator("Keltner Channels", overlay=true)
length = input.int(20, "EMA Length")
atrMult = input.float(1.5, "ATR Multiplier")
atrLen = input.int(10, "ATR Length")
mid = ta.ema(close, length)
upper = mid + atrMult * ta.atr(atrLen)
lower = mid - atrMult * ta.atr(atrLen)
longSignal = ta.crossover(close, upper)
shortSignal = ta.crossunder(close, mid)
plotshape(longSignal, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
plotshape(shortSignal, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
p1 = plot(upper, "Upper KC", color=color.new(color.purple, 0))
p2 = plot(lower, "Lower KC", color=color.new(color.purple, 0))
plot(mid, "Mid KC", color=color.orange)
fill(p1, p2, color=color.new(color.purple, 90))