strategy · own pane · open source
TTM Squeeze breakout strategy
TTM Squeeze breakout: buy when the Bollinger-inside-Keltner squeeze releases with positive momentum, exit when momentum turns negative. Rules, code, backtest. Deepwick Script runs a subset of Pine Script.
What the TTM Squeeze Breakout strategy does
TTM Squeeze breakout: when Bollinger Bands move inside the Keltner Channel (volatility compression), wait for the squeeze to release and price to break above the BB basis.
- The histogram shows momentum direction; positive = bullish pressure building.
- Combine with a higher-timeframe trend for stronger entries.
- 20-period is the canonical TTM setting.
Entry and exit rules
Language reference: Deepwick Script.
Default inputs
| Input | Default | Min | Max |
|---|---|---|---|
Length | 20 | 5 | 50 |
BB Mult | 2 | 1 | 3 |
KC Mult | 1.5 | 1 | 3 |
Stop Loss % | 2 | 0.5 | 10 |
Take Profit % | 6 | 0 | 20 |
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().
Source code
Deepwick Script, a subset of Pine Script · read-only
//@version=6
strategy("TTM Squeeze Breakout", overlay=false, 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=50, 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)
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)
colorUp = input.color("color.green", "Color Up")
colorDown = input.color("color.red", "Color Down")
colorNeutral = input.color("color.gray", "Color Neutral")
[bm, bu, bl] = ta.bb(close, len, bbMult)
[km, ku, kl] = ta.kc(close, len, kcMult)
sqz = bl > kl and bu < ku
mid = math.avg(math.avg(ta.highest(high, len), ta.lowest(low, len)), ta.sma(close, len))
mom = ta.linreg(close - mid, len, 0)
longSignal = strategy.position_size == 0 and sqz[1] and not sqz and close > bm and mom > 0
exitSignal = strategy.position_size > 0 and mom < 0
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="Momentum faded")
hline(0, "Zero", color=colorNeutral, linestyle=hline.style_dotted)
p_Momentum = plot(mom, "Momentum", color=mom >= 0 ? colorUp : colorDown, style=plot.style_columns)
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, "TTM squeeze long entry", "Squeeze released with bullish momentum")
alertcondition(exitSignal, "TTM exit", "Momentum turned negative")
Run it in Deepwick
- Open a chart of any crypto pair or CFD.
- Click “Scripts” and add this strategy.
- Press Run and read the trades in the Strategy Tester.
FAQ
How does the TTM Squeeze work?
When Bollinger Bands contract inside the Keltner Channel, volatility is compressed. The release is the bar where they expand back outside; the momentum histogram gives the direction.
Why so few trades?
It needs a squeeze release, a close above the basis and positive momentum on the same bar. On higher timeframes that is rare, so check the trade count before reading the statistics.
No comments yet.
Sign in to comment.