Volatility
TTM Squeeze Signals: Compression, Release and a Pine Example
Separate squeeze release from momentum zero crosses. Review an explicit BB/Keltner Pine Script v6 example, histogram units and closed-bar alert rules.
TTM Squeeze Signal Interpretation
Quick-reference guide to 5 signal types you will see on the chart.
| Signal Type | Indicator Condition | Market Meaning | Interpretation limits |
|---|---|---|---|
| Compression state | Both Bollinger Bands are strictly inside the Keltner-style channel. | The close dispersion is small relative to the chosen ATR channel. Red dots show this state. | Compression is directionless and does not guarantee a large subsequent move. |
| Bullish release | The previous bar was in compression; the current closed bar is not, and momentum is positive. | The example marks the first release bar with a positive histogram. | A simultaneous zero crossover is not required; a release can fail. |
| Bearish release | The previous bar was in compression; the current closed bar is not, and momentum is negative. | The first release bar has a negative histogram. | The condition provides a direction label, not an executable trade or target. |
| Positive momentum easing | Momentum remains above zero but is below its previous value. | The positive histogram is shrinking and turns blue. | This is a momentum state, not proof of a price top. |
| Negative momentum easing | Momentum remains below zero but is above its previous value. | The negative histogram is moving toward zero and turns orange. | This does not itself establish a price bottom or a new squeeze. |
TTM Squeeze Pine Script Signal Code
Educational indicator example. Review its exact rules and compare its plots with your intended calculation in TradingView. It does not place orders or establish profitability.
Pine Script v6
//@version=6
indicator("BB/Keltner Squeeze Learning Example", overlay=false)
length = input.int(20, "Calculation Length", minval=2)
bbMult = input.float(2.0, "BB Deviation Multiplier", minval=0.1)
kcMult = input.float(1.5, "KC ATR Multiplier", minval=0.1)
showDots = input.bool(true, "Show Squeeze Dots")
showHistogram = input.bool(true, "Show Histogram")
// Explicit educational variant; not a replica of proprietary TTM software.
basis = ta.sma(close, length)
bbWidth = bbMult * ta.stdev(close, length)
kcWidth = kcMult * ta.atr(length)
bbUpper = basis + bbWidth
bbLower = basis - bbWidth
kcUpper = basis + kcWidth
kcLower = basis - kcWidth
bandsReady = not na(bbWidth) and not na(kcWidth)
squeezeOn = bandsReady and bbUpper < kcUpper and bbLower > kcLower
midRange = (ta.highest(high, length) + ta.lowest(low, length)) / 2
center = (midRange + basis) / 2
// Regression endpoint of detrended price, not a regression slope.
momentum = ta.linreg(close - center, length, 0)
released = barstate.isconfirmed and bandsReady and squeezeOn[1] and not squeezeOn
bullRelease = released and momentum > 0
bearRelease = released and momentum < 0
started = barstate.isconfirmed and bandsReady and bandsReady[1] and squeezeOn and not squeezeOn[1]
histColor = momentum > 0 ? (momentum > momentum[1] ? color.aqua : color.blue) : (momentum < momentum[1] ? color.red : color.orange)
plot(showHistogram ? momentum : na, "Momentum", histColor, 2, plot.style_histogram)
plot(showDots and bandsReady and barstate.isconfirmed ? 0 : na, "Squeeze State", squeezeOn ? color.red : color.green, 3, plot.style_circles)
hline(0, "Zero", color.gray)
plotshape(bullRelease, "Bullish Release", shape.triangleup, location.bottom, color.green)
plotshape(bearRelease, "Bearish Release", shape.triangledown, location.top, color.red)
alertcondition(started, "Compression Started", "Bollinger Bands entered the configured Keltner-style channel")
alertcondition(bullRelease, "Positive Momentum Release", "Compression ended with positive momentum")
alertcondition(bearRelease, "Negative Momentum Release", "Compression ended with negative momentum")Example settings for TTM Squeeze
Record the inputs used by the example. These settings are not an optimized trading recommendation.
| Parameter | Default | Description |
|---|---|---|
| Calculation Length | 20 | Used by SMA, standard deviation, ATR, high-low midpoint and the regression endpoint. Their combined history requirements mean the histogram needs more than one window to warm up. |
| BB Deviation Multiplier | 2.0 | Scales close standard deviation. With the other values fixed, reducing it makes the inside-channel condition easier to meet. |
| KC ATR Multiplier | 1.5 | Scales Wilder-smoothed true range around the same SMA basis. Increasing it widens the channel and makes compression easier to detect, not harder. |
| Show Squeeze Dots / Show Histogram | true / true | Display controls only. Alerts remain available when either plot is hidden. |
Turn the condition into an explicit rule
Specify the calculation, confirmation time, entry and exit rules before asking Pineify to draft or revise Pine Script. Review the code and simulate realistic costs before evaluating a strategy.
Explore Pine Script codingOfficial calculation and usage references
FAQ
TTM Squeeze Signals FAQ
Is this the official TTM Squeeze source code?
No. TTM Squeeze is associated with John Carter and Simpler Trading. This is an independently specified educational BB/Keltner variant. It uses an SMA basis, Wilder ATR channel and a regression endpoint of detrended price. These explicit choices need not match a commercial TTM product or another platform implementation.
How is a squeeze release different from a zero cross?
A release changes the compression state from true to false. A zero cross changes the sign of the momentum series. Either can occur without the other. If yesterday was compressed and today is not with momentum +3, this example gives a bullish release even if yesterday momentum was already +2. Another positive reading tomorrow is not a second release.
What does the histogram measure in this example?
It takes close minus the average of the rolling high-low midpoint and the close SMA, then evaluates a linear regression endpoint over that series. The output has price units. It is not a regression slope, percentage, probability or normalized score. A value of +2 therefore cannot serve as a universal overbought threshold across differently priced instruments.
How can I verify compression numerically?
Suppose the hypothetical shared basis is 100, BB half-width is 2 and KC half-width is 3. BB spans 98 to 102 inside KC at 97 to 103, so compression is true. If the BB half-width becomes 3.5 with KC unchanged, compression becomes false. This example uses strict containment: equal widths are outside its compression definition.
Does ATR ignore overnight gaps?
No. True range considers the previous close as well as the current high and low, and ATR smooths that true range. A single bar true range and an average of true range are different series. This example consistently uses ta.atr for channel width and has no switch between raw true range and ATR.
Does the example detect double squeezes or divergence?
No. A second release is not automatically a failed first breakout followed by a stronger setup. Such a rule needs definitions for failure, timing and direction. The code also has no price-pivot divergence detector. No performance or institutional-order inference is assigned to repeated releases.
Can the dots or histogram change before the bar closes?
The histogram reflects the developing bar. Dots and alert conditions are gated at the confirmed close, so the open bar does not display a confirmed dot. The code uses no future bars. Data corrections or changed inputs can still alter past calculations.
Which squeeze filter or timeframe is best?
No measured ranking is available here. RSI, ADX, trend and session filters create different strategies that require explicit entry and exit rules and independent testing. A compression flag alone supplies neither a direction forecast nor a reason to increase position size.