strategy · on price · open source

Donchian channel breakout strategy (20 / 10, Turtle-style)

Turtle-style Donchian breakout: buy a close above the 20-bar high, exit below the 10-bar low, 2.5×ATR stop. Code plus a backtest with next-bar fills and costs. Deepwick Script runs a subset of Pine Script.

v1Updated 3 Oct 2026▲ 0 users
Running…
Loading chart…

What the Donchian Breakout strategy does

Turtle-style breakout: go long when price closes above the highest high of the last N bars, exit on a close below the lowest low of a shorter window. Includes an ATR stop.

Open the Strategy Tester to see trades, equity and drawdown.

Entry and exit rules

    Language reference: Deepwick Script.

    Default inputs

    InputDefaultMinMax
    Entry channel202—
    Exit channel102—
    ATR stop2.5——

    How Deepwick fills this strategy

    • Market orders fill at the next bar's open.
    • Stops and limits follow the bar's path: open → nearer extreme → farther extreme → close.
    • Gaps fill at the open.
    • Commission is charged on every fill, and slippage applies to market and stop fills, as set in strategy().

    More on how backtests work

    Source code

    Deepwick Script, a subset of Pine Script · read-only

    //@version=6
    strategy("Donchian Breakout Strategy", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=20, commission_type=strategy.commission.percent, commission_value=0.05)
    entryLen = input.int(20, "Entry channel", minval=2)
    exitLen = input.int(10, "Exit channel", minval=2)
    atrMult = input.float(2.5, "ATR stop", step=0.1)
    hi = ta.highest(high, entryLen)[1]
    lo = ta.lowest(low, exitLen)[1]
    plot(hi, "Entry level", color=color.green)
    plot(lo, "Exit level", color=color.red)
    if strategy.position_size == 0 and close > hi
        strategy.entry("Long", strategy.long)
    if strategy.position_size > 0
        strategy.exit("Stop", stop=strategy.position_avg_price - ta.atr(14) * atrMult)
        if close < lo
            strategy.close("Long", comment="Channel exit")
    

    Run it in Deepwick

    1. Open a chart of any crypto pair or CFD.
    2. Click “Scripts” and add this strategy.
    3. Press Run and read the trades in the Strategy Tester.
    Start free

    FAQ

    Does the Donchian breakout work intraday?

    It can be tested on any timeframe from 1 minute to weekly. On low timeframes more breakouts fail and costs weigh more per trade, so compare the trades count and fees in the table before drawing conclusions.

    Is this the original Turtle Trading system?

    It borrows the Turtle idea (20-bar breakout entry, 10-bar exit, ATR-based stop) but is long-only, uses 20% of equity per trade and has no pyramiding or unit sizing, so it is a simplified version.

    Comments

    No comments yet.

    Sign in to comment.