strategy · on price · open source

Keltner Channel Breakout

Deepwick · @deepwickv1Updated 2 Oct 2026▲ 0 users
Running…
Loading chart…

About

Keltner Channel breakout: enter when price closes above the upper band (EMA + ATR multiple), exit when it returns to the basis.

  • Tighter Mult for faster entries; raise it for stronger breakouts only.
  • Combine with a volume spike filter for higher-conviction entries.
  • Plot the basis and upper band on the chart for visual confirmation.

Source code

//@version=5
strategy("Keltner Channel Breakout", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_type=strategy.commission.percent, commission_value=0.05)
len = input.int(20, "Length", minval=5, maxval=100, step=1)
mult = input.float(2, "ATR Mult", minval=1, maxval=3, step=0.1)
stopPct = input.float(2, "Stop Loss %", minval=0.5, maxval=10, step=0.1)
tpPct = input.float(6, "Take Profit %", minval=0, maxval=20, step=0.1)
[km, ku, kl] = ta.kc(close, len, mult)
longSignal = strategy.position_size == 0 and close > ku
exitSignal = strategy.position_size > 0 and close < km
if longSignal
    strategy.entry("Long", strategy.long)
if strategy.position_size > 0
    strategy.exit("Risk", stop=stopPct > 0 ? strategy.position_avg_price * (1 - stopPct / 100) : na, limit=tpPct > 0 ? strategy.position_avg_price * (1 + tpPct / 100) : na)
if exitSignal
    strategy.close("Long", comment="Back to basis")
p_Basis = plot(km, "Basis", color=color.gray, linewidth=1)
p_Upper_KC = plot(ku, "Upper KC", color=color.orange, linewidth=1)
p_Lower_KC = plot(kl, "Lower KC", color=color.orange, linewidth=1)
plotshape(longSignal, "Long", style=shape.triangleup, location=location.belowbar, color=color.green, text="L")
plotshape(exitSignal, "Exit", style=shape.triangledown, location=location.abovebar, color=color.red, text="X")
alertcondition(longSignal, "KC long entry", "Price broke above Keltner upper")
alertcondition(exitSignal, "KC exit", "Price returned to Keltner basis")

Comments

No comments yet.

Sign in to comment.