indicator · on price · open source
Keltner Channel
Running…
Loading chart…
About
Keltner Channel uses an EMA of the typical price plus/minus an ATR envelope — smoother than Bollinger and a common trend filter.
- Price above the upper rail = trend up; below the lower rail = trend down.
- Channel width tracks ride regime; tight KC + BB squeeze = coiled spring.
Source code
//@version=5
indicator("Keltner Channel", overlay=true)
len = input.int(20, "Length", minval=2, maxval=200)
mult = input.float(2, "ATR multiplier", minval=0.1, maxval=5, step=0.1)
src = input.source("close", "Source")
[m, u, l] = ta.kc(src, len, mult)
p_KC_Mid = plot(m, "KC Mid", color=color.orange, linewidth=2)
p_KC_Upper = plot(u, "KC Upper", color=color.green)
p_KC_Lower = plot(l, "KC Lower", color=color.green)
fill(p_KC_Upper, p_KC_Lower, color=color.new(color.green, 90))
alertcondition(ta.crossover(close, u), "Above upper rail", "Close crossed above the Keltner upper rail")
alertcondition(ta.crossunder(close, l), "Below lower rail", "Close crossed below the Keltner lower rail")
No comments yet.
Sign in to comment.