strategy · on price · open source

Bollinger Squeeze Breakout strategy

Bollinger Squeeze Breakout is a free open-source strategy by @deepwick. Volatility squeeze breakout: when Bollinger Bands move inside the Keltner Channel (squeeze… Deepwick Script runs a subset of Pine Script.

Deepwick · @deepwickv1Updated 3 Nov 2026▲ 0 users
Running…
Loading chart…

What Bollinger Squeeze Breakout does

Volatility squeeze breakout: when Bollinger Bands move inside the Keltner Channel (squeeze = vol compression), then buy the first close above the upper band within Squeeze lookback bars after the squeeze.

  • Tighter bbMult keeps entries closer to the basis; raise kcMult for stricter squeeze detection.
  • Exit when price closes back below the basis, or on the stop / target.
  • Combine with a momentum filter for cleaner breakouts.

Source code

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

//@version=6
strategy("Bollinger Squeeze 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)
bbMult = input.float(2, "BB Mult", minval=1, maxval=3, step=0.1)
kcMult = input.float(1.5, "KC Mult", minval=1, maxval=3, step=0.1)
squeezeLookback = input.int(5, "Squeeze lookback", minval=1, maxval=50, 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)
colorNeutral = input.color("color.gray", "Color  Neutral")
colorLine = input.color("color.blue", "Color  Line")
colorMid = input.color("color.orange", "Color  Mid")
colorUp = input.color("color.green", "Color  Up")
colorDown = input.color("color.red", "Color  Down")
[bm, bu, bl] = ta.bb(close, len, bbMult)
[km, ku, kl] = ta.kc(close, len, kcMult)
squeeze = bl > kl and bu < ku
// A breakout only counts soon after a squeeze: BB inside KC within the last squeezeLookback bars.
recentSqueeze = ta.barssince(squeeze) <= squeezeLookback
longSignal = strategy.position_size == 0 and not squeeze and recentSqueeze and close > bu
exitSignal = strategy.position_size > 0 and close < bm
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(bm, "Basis", color=colorNeutral, linewidth=1)
p_Upper_BB = plot(bu, "Upper BB", color=colorLine, linewidth=1)
p_Lower_BB = plot(bl, "Lower BB", color=colorLine, linewidth=1)
p_Upper_KC = plot(ku, "Upper KC", color=colorMid, linewidth=1)
p_Lower_KC = plot(kl, "Lower KC", color=colorMid, 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, "Squeeze breakout long", "Bollinger broke above Keltner upper")
alertcondition(exitSignal, "Squeeze exit", "Price returned to Bollinger basis")

Comments

No comments yet.

Sign in to comment.