TTM Squeeze Indicator — Free Pine Script v6 for TradingView
- ttm-squeeze-indicator.pine — the complete Pine Script v6 source
- README-FIRST.md — what it does and how to install it
- FREE-LICENSE.md — the free-edition license terms
About this product
TTM Squeeze Indicator is a free Pine Script v6 indicator by Script Master Labs. It measures volatility compression (Bollinger Bands inside Keltner Channels) and plots a linear-regression momentum histogram. The complete source is printed in full on this page and in the free download — paste it into TradingView's Pine Editor and it runs on TradingView's free plan. No payment, no account, no subscription.
What it computes, in its own terms: it volatility compression — whether the Bollinger Bands sit inside the Keltner Channels — and plots a momentum histogram: the linear regression of price against its recent midline, the classic TTM construction, colored by sign and direction, with a dot marking the squeeze state. Compression describes the recent past; it does not predict the size or direction of any future move.
How to use it
Open TradingView's Pine Editor, create a new blank script, paste the source, save, and click Add to chart. Adjust the inputs from the gear icon. The full source is printed on this page below, and the free download carries the same source file with an install README and the free-edition license.
Free edition vs paid edition
The script file is the complete indicator — the same Pine Script v6 source sold in the paid edition (https://dual.scriptmasterlabs.com/product/ttm-squeeze-indicator, $29 one-time). The paid edition adds the full written user guide, the evidence receipt, and the licensing and security reviews. Nothing in the script is held back from the free edition.
More free tools — free Pine Script v6 indicators and strategies, free trading calculators and a free x402 pre-payment trust check — are collected on the Free Tools hub. Educational software, not financial advice: it measures and draws a stated rule; it does not predict price and shows no win rate.
The complete Pine Script v6 source — free, on this page
TTM Squeeze Indicator is a free Pine Script v6 indicator by Script Master Labs. It measures volatility compression (Bollinger Bands inside Keltner Channels) and plots a linear-regression momentum histogram. The complete source is printed in full on this page and in the free download — paste it into TradingView's Pine Editor and it runs on TradingView's free plan. No payment, no account, no subscription.
// © 2026 Script Master Labs LLC — TTM Squeeze Indicator for TradingView
// Research-based, original SML engineering. This indicator MEASURES
// volatility compression (Bollinger Bands inside Keltner Channels) and plots
// a linear-regression momentum histogram. Compression describes the recent
// past; it does not predict the size or direction of any future move.
//@version=6
indicator("SML TTM Squeeze Indicator", shorttitle = "SML TTM Squeeze", overlay = false, precision = 4)
// ── Inputs ──────────────────────────────────────────────────────────────────
length = input.int(20, "Length (BB / KC / momentum)", minval = 5, maxval = 100)
bbMult = input.float(2.0, "Bollinger Band multiplier (stdev)", minval = 0.5, step = 0.1)
kcMult = input.float(1.5, "Keltner Channel multiplier (ATR)", minval = 0.5, step = 0.1)
useTrueRange = input.bool(true, "Keltner uses True Range (classic TTM)")
// ── Bollinger Bands ─────────────────────────────────────────────────────────
basis = ta.sma(close, length)
dev = bbMult * ta.stdev(close, length)
bbUpper = basis + dev
bbLower = basis - dev
// ── Keltner Channels ────────────────────────────────────────────────────────
// Classic TTM construction: EMA basis; range is ATR when "use True Range" is
// on, otherwise the SMA of the bar range.
kcBasis = ta.ema(close, length)
rng = useTrueRange ? ta.atr(length) : ta.sma(high - low, length)
kcUpper = kcBasis + rng * kcMult
kcLower = kcBasis - rng * kcMult
// ── Squeeze state ───────────────────────────────────────────────────────────
squeezeOn = bbLower > kcLower and bbUpper < kcUpper // BB fully inside KC
squeezeOff = not squeezeOn
fired = squeezeOff and squeezeOn[1] // first bar out of squeeze
// ── Momentum (linear regression of price vs. midline, classic TTM) ─────────
midline = math.avg(math.avg(ta.highest(high, length), ta.lowest(low, length)), ta.sma(close, length))
momentum = ta.linreg(close - midline, length, 0)
posRising = momentum > 0 and momentum > momentum[1]
posFalling = momentum > 0 and momentum <= momentum[1]
negFalling = momentum <= 0 and momentum < momentum[1]
negRising = momentum <= 0 and momentum >= momentum[1]
momColor = posRising ? color.new(color.aqua, 0) : posFalling ? color.new(color.blue, 0) : negFalling ? color.new(color.red, 0) : color.new(color.maroon, 0)
plot(momentum, "Momentum", style = plot.style_histogram, color = momColor, linewidth = 2)
plot(0, "Zero line", color = color.new(color.gray, 50))
// Squeeze dots on the zero line: red = squeeze on, green = squeeze released
// this bar, gray = no squeeze.
dotColor = fired ? color.new(color.lime, 0) : squeezeOn ? color.new(color.red, 0) : color.new(color.gray, 0)
plot(0, "Squeeze dots", style = plot.style_circles, color = dotColor, linewidth = 3)
// Optional band view in the data window (values only; pane is the histogram).
plot(bbUpper - kcUpper, "BB upper minus KC upper (< 0 while squeezed)", display = display.data_window)
plot(bbLower - kcLower, "BB lower minus KC lower (> 0 while squeezed)", display = display.data_window)
alertcondition(squeezeOn and not squeezeOn[1], title = "Squeeze ON", message = "TTM squeeze turned ON on {{exchange}}:{{ticker}} ({{interval}}): Bollinger Bands moved inside Keltner Channels.")
alertcondition(fired, title = "Squeeze FIRED (released)", message = "TTM squeeze released on {{exchange}}:{{ticker}} ({{interval}}). Release describes volatility state only; it is not a direction signal.")
Questions about this product
Is there a free Pine Script for the TTM squeeze on TradingView?
Yes. Script Master Labs publishes this TTM Squeeze Indicator as a free Pine Script v6 download on SML Dual Market (https://dual.scriptmasterlabs.com/product/free-ttm-squeeze-indicator). The complete source is printed in full on the product page and in the free download — no payment, no account, no subscription.
How do I use the TTM Squeeze Indicator?
Open TradingView's Pine Editor, create a new blank script, paste the source, click Save, then Add to chart. Adjust the inputs from the gear icon. TradingView's first-steps page shows where the editor opens: https://tradingview.com/pine-script-docs/primer/first-steps
Does it work on TradingView's free plan?
Yes. Paste the source into TradingView's Pine Editor and add it to your chart; the free plan runs custom indicators.
Is the free edition the complete script?
Yes — the same Pine Script v6 source file sold in the paid edition ($29 one-time). The paid edition adds the full written user guide, the evidence receipt, and the licensing and security reviews; nothing in the script itself is held back.