strategy · on price · open source
Donchian Channel Breakout strategy
Donchian Channel Breakout is a free open-source strategy by @deepwick. Turtle-style Donchian Channel breakout: enter on a close above the N-bar high, exit on a… Deepwick Script runs a subset of Pine Script.
Running…
Loading chart…
What Donchian Channel Breakout does
Turtle-style Donchian Channel breakout: enter on a close above the N-bar high, exit on a close below the M-bar low, with a stop at entry minus ATR × mult (anchored to the entry, not trailing) and an optional take-profit. The plain 20/10 version is Donchian Breakout Strategy.
- 20/10 is the canonical Turtle pair; 55/20 for slower swings.
- Raise
ATR Stop Multfor a wider stop, lower for tighter risk control. - Combine with an ADX > 25 filter for trending environments only.
Source code
Deepwick Script, a subset of Pine Script · read-only
//@version=6
strategy("Donchian 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, "Entry Channel", minval=5, maxval=200, step=1)
exitLen = input.int(10, "Exit Channel", minval=5, maxval=100, step=1)
atrMult = input.float(2.5, "ATR Stop Mult", minval=1, maxval=5, step=0.1)
tpPct = input.float(6, "Take Profit %", minval=0, maxval=20, step=0.1)
colorUp = input.color("color.green", "Color Up")
colorDown = input.color("color.red", "Color Down")
hi = ta.highest(high, len)[1]
lo = ta.lowest(low, exitLen)[1]
longSignal = strategy.position_size == 0 and close > hi
exitSignal = strategy.position_size > 0 and close < lo
if longSignal
strategy.entry("Long", strategy.long)
if strategy.position_size > 0
strategy.exit("ATR stop", stop=strategy.position_avg_price - ta.atr(14) * atrMult)
if tpPct > 0
strategy.exit("TP", limit=strategy.position_avg_price * (1 + tpPct / 100))
if exitSignal
strategy.close("Long", comment="Channel exit")
p_Entry_Level = plot(hi, "Entry Level", color=colorUp, linewidth=1)
p_Exit_Level = plot(lo, "Exit Level", color=colorDown, linewidth=1)
plotshape(longSignal, "Long", style=shape.triangleup, location=location.belowbar, color=colorUp, text="L")
plotshape(exitSignal, "Exit", style=shape.triangledown, location=location.abovebar, color=colorDown, text="X")
alertcondition(longSignal, "Donchian long entry", "Price broke above Donchian high")
alertcondition(exitSignal, "Donchian exit", "Price broke below Donchian exit low")
No comments yet.
Sign in to comment.