strategy · on price · open source

Ichimoku cloud breakout strategy (9 / 26 / 52)

Ichimoku strategy: buy a Tenkan/Kijun bullish cross above the cloud, exit when price closes below it. Rules, code and 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 Ichimoku Cloud Breakout strategy does

Ichimoku Kinko Hyo cloud breakout: long when Tenkan-sen crosses above Kijun-sen AND price is above the cloud (SpanA and SpanB), exit on a cloud re-entry.

  • The cloud (SpanA/SpanB) is plotted as a filled band.
  • Combine with a higher-timeframe trend for confirmation.
  • 9/26/52 is the canonical Ichimoku setting.

Entry and exit rules

    Language reference: Deepwick Script.

    Default inputs

    InputDefaultMinMax
    Tenkan Length9550
    Kijun Length2610100
    Senkou Span Length5220200
    Stop Loss %20.510
    Take Profit %6020

    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("Ichimoku Cloud 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)
    conv = input.int(9, "Tenkan Length", minval=5, maxval=50, step=1)
    base = input.int(26, "Kijun Length", minval=10, maxval=100, step=1)
    span = input.int(52, "Senkou Span Length", minval=20, maxval=200, step=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)
    colorLine = input.color("color.blue", "Color  Line")
    colorDown = input.color("color.red", "Color  Down")
    colorUp = input.color("color.green", "Color  Up")
    tenkan = (ta.highest(high, conv) + ta.lowest(low, conv)) / 2
    kijun = (ta.highest(high, base) + ta.lowest(low, base)) / 2
    spanA = (tenkan + kijun) / 2
    spanB = (ta.highest(high, span) + ta.lowest(low, span)) / 2
    cloudTop = math.max(spanA, spanB)
    cloudBot = math.min(spanA, spanB)
    longSignal = strategy.position_size == 0 and ta.crossover(tenkan, kijun) and close > cloudTop
    exitSignal = strategy.position_size > 0 and close < cloudBot
    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="Cloud re-entry")
    p_Tenkan = plot(tenkan, "Tenkan", color=colorLine, linewidth=1)
    p_Kijun = plot(kijun, "Kijun", color=colorDown, linewidth=1)
    p_Span_A = plot(spanA, "Span A", color=colorUp, linewidth=1)
    p_Span_B = plot(spanB, "Span B", color=colorDown, linewidth=1)
    fill(p_Span_A, p_Span_B, color=color.new(colorUp, 80))
    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, "Ichimoku long entry", "Tenkan crossed above Kijun above the cloud")
    alertcondition(exitSignal, "Ichimoku exit", "Price re-entered the cloud from below")
    

    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

    What Ichimoku settings does it use?

    The classic 9 / 26 / 52. All three are inputs, so you can test other sets, for example for 24/7 crypto markets.

    Why exit only below the cloud?

    A close back inside the cloud is not enough; the script waits for a close below the bottom, which gives trends room but makes exits later. The 2% stop often acts first.

    Comments

    No comments yet.

    Sign in to comment.