Concept 50 / 52·Volatility·Volatility regimes
‹ Trailing StopVWAP ›

Volatility Squeeze in Pine Script

TTM Squeeze · Bollinger squeeze · BB inside KC · squeeze momentum

A compression regime read as the Bollinger Bands sitting inside the Keltner channel; the event is the release, read in the direction the momentum histogram shows.

Reads best on: Daily and 4-hour charts of stocks, index futures and crypto, where compressions last days and releases run; on 1 to 5-minute charts squeezes fire constantly and most releases fail.
On this page: the Pine v6 script, checked, drawn on real NVDA bars. Backtest it free, costs charged, every trade on the chart.
01

Definition

A volatility squeeze is a stretch of unusually quiet trading, read from the relationship between two bands. When the Bollinger Bands, whose width comes from the standard deviation of closes, contract until they sit inside the Keltner channel, whose width comes from average true range, the market is quieter than its own typical range. The concept belongs to the volatility regimes family. It does not say which way price will go, only that the current calm is unlikely to last, and it pairs a momentum reading with the squeeze to pick the side when the calm ends.

Volatility clusters and mean-reverts. Quiet periods are followed by active ones and active ones fade back to quiet, which is why a compression tends to end in an expansion. The squeeze converts that into a rule with two thresholds, the deviation bands and the ATR channel, so it fires when dispersion has fallen below the market's normal bar size. A second effect: in a squeeze the range is narrow, so a stop beyond it is close and the release's risk is small and defined, even though only some releases run.

John Carter's TTM Squeeze made the reading standard: 20-period Bollinger Bands at 2 deviations against a 20-period Keltner channel at 1.5 ATR, dots on a zero line that change colour while the squeeze is on, and a momentum histogram beneath. The library script follows that layout in a pane, with amber dots during the squeeze and a mark on the release bar. Its histogram is a linear regression of the close minus a centre, the average of the 20-bar range midpoint and the 20-bar moving average, so it measures the drift of price away from its recent centre.

On the chart the dots turn amber and stay amber for several bars, sometimes dozens, while the histogram drifts near zero or builds slowly in one direction. The release is the first bar where the dots turn grey, meaning the Bollinger Bands have widened back outside the Keltner channel. The library marks that bar long if the histogram is above zero and short if it is below. Expect a burst of range over the next bars, expect some releases to reverse within a few bars, and expect the histogram's colour, bright while it strengthens and faded while it weakens, to tell you whether the release is holding.

02

Reading the chart

Read the squeeze as a state, then the histogram as direction, then the release as the trigger.

  1. Watch the dots. Amber means the Bollinger Bands are inside the Keltner channel and the squeeze is on; grey means the bands are outside and the market is moving normally.
  2. Count the bars in the squeeze. A compression of 6 bars or more has stored more energy than a 2-bar one, and the releases that follow long squeezes tend to run further.
  3. Read the histogram sign. Above zero means price is drifting above its recent centre, below zero the reverse; the sign on the release bar sets the direction the library script marks.
  4. Read the histogram colour. Bright means momentum is strengthening bar over bar, faded means it is weakening; a release with a bright histogram is the stronger release.
  5. Read the release bar. The first grey dot after amber, confirmed at the close, is the trigger, and the library marks a long above zero momentum and a short below it.
  6. Cross-check the price chart. The Bollinger template tints its fill amber during the same squeeze, and a breakout of the compressed range on the price chart confirms the release.
03

The maths

The squeeze compares two sets of bands of the same length, and the histogram is a linear regression of the close's distance from a centre.

BBUppert=SMAn(C)+kbb σn(C)\mathrm{BBUpper}_t = \mathrm{SMA}_n(C) + k_{\mathrm{bb}} \, \sigma_n(C)
BBLowert=SMAn(C)−kbb σn(C)\mathrm{BBLower}_t = \mathrm{SMA}_n(C) - k_{\mathrm{bb}} \, \sigma_n(C)
KCUppert=EMAn(C)+kkc ATRn\mathrm{KCUpper}_t = \mathrm{EMA}_n(C) + k_{\mathrm{kc}} \, \mathrm{ATR}_n
KCLowert=EMAn(C)−kkc ATRn\mathrm{KCLower}_t = \mathrm{EMA}_n(C) - k_{\mathrm{kc}} \, \mathrm{ATR}_n
Squeezet={1BBUppert<KCUppert and BBLowert>KCLowert0otherwise\mathrm{Squeeze}_t = \begin{cases} 1 & \mathrm{BBUpper}_t < \mathrm{KCUpper}_t \text{ and } \mathrm{BBLower}_t > \mathrm{KCLower}_t \\ 0 & \text{otherwise} \end{cases}
Centret=12(HHn+LLn2+SMAn(C))\mathrm{Centre}_t = \frac{1}{2} \left( \frac{\mathrm{HH}_n + \mathrm{LL}_n}{2} + \mathrm{SMA}_n(C) \right)
Momt=LinRegn(C−Centre)\mathrm{Mom}_t = \mathrm{LinReg}_n(C - \mathrm{Centre})
Releaset={1Squeezet−1=1 and Squeezet=00otherwise\mathrm{Release}_t = \begin{cases} 1 & \mathrm{Squeeze}_{t-1} = 1 \text{ and } \mathrm{Squeeze}_t = 0 \\ 0 & \text{otherwise} \end{cases}
CCthe series of closes
nnthe length of every window, 20 by default
SMAn(C)\mathrm{SMA}_n(C)the simple moving average of the closes over n bars
EMAn(C)\mathrm{EMA}_n(C)the exponential moving average of the closes over n bars
σn(C)\sigma_n(C)the standard deviation of the closes over n bars
ATRn\mathrm{ATR}_nthe average true range over n bars
kbbk_{bb}the Bollinger multiplier, 2 by default
kkck_{kc}the Keltner multiplier, 1.5 by default
BBUppert\mathrm{BBUpper}_tthe upper Bollinger Band
BBLowert\mathrm{BBLower}_tthe lower Bollinger Band
KCUppert\mathrm{KCUpper}_tthe upper Keltner line
KCLowert\mathrm{KCLower}_tthe lower Keltner line
Squeezet\mathrm{Squeeze}_t1 while the squeeze is on, 0 otherwise
Squeezet−1\mathrm{Squeeze}_{t-1}the squeeze state of the previous bar
HHn\mathrm{HH}_nthe highest high of the last n bars
LLn\mathrm{LL}_nthe lowest low of the last n bars
Centret\mathrm{Centre}_tthe centre price the momentum is measured from
LinRegn\mathrm{LinReg}_nthe value at the current bar of a linear regression fitted over n bars
Momt\mathrm{Mom}_tthe momentum histogram
Releaset\mathrm{Release}_t1 on the bar the squeeze ends, 0 otherwise

Both band sets use one length, 20 by default. In the library script the Keltner channel's range average uses that same length, and its lines use true range, so gaps count.

The histogram is the value at the current bar of a linear regression line fitted through the last n values of the close minus the centre. It is a smoothed drift, positive when price sits above its recent centre.

The colour of the histogram compares each value with the previous one: brighter while the momentum is growing, faded while it is shrinking, in both directions.

The release is a one-bar event: squeeze on the previous bar and off on this one. The script marks it once, so a squeeze that resumes a few bars later produces a new release later.

04

Inputs that matter

InputTypicalWhat changing it does
Length20Shorter finds more, briefer squeezes and releases sooner; longer finds fewer, longer compressions whose releases carry further.
Bollinger multiplier2Lower makes the deviation bands narrower so the squeeze fires more easily; higher makes it rarer and stricter.
Keltner multiplier1.5Higher widens the channel and makes squeezes more frequent; lower narrows it and demands a deeper compression.
05

In practice

  • As a breakout timer: the release is the trigger, the histogram the side, and the stop sits beyond the compressed range, which is the event the library script marks and alerts on.
  • As a filter for other setups: a breakout signal from another concept that fires while the dots are amber is early; wait for the release before trusting it.
  • As a multi-timeframe map: a daily squeeze with an intraday release in the same direction is a stronger setup than either alone, because the larger compression feeds the smaller one.
  • As a watchlist scan: instruments whose dots are amber are the candidates for the next session, and the ones with the longest squeezes go to the top of the list.
  • As a risk frame: the narrow range of the squeeze gives a natural stop just beyond it, and the release bar's range sets the first target as a multiple of that.
  • As a direction read on its own: the histogram is a smooth momentum line, and its sign and colour can filter entries even outside a squeeze.
06

Where it goes wrong

  • Entering during the squeeze. The compression can last for weeks and the side is unknown; wait for the release bar.
  • Ignoring the histogram. A release with momentum near zero has no side and reverses often; the rule keeps releases with a clear sign and a bright colour.
  • Trading every release on 1 and 5-minute charts. Squeezes fire constantly there and most releases fail; read the squeeze on 1-hour to daily bars.
  • Expecting every release to trend. Some releases are one wide bar and a return; size for the failure and let the stop beyond the range take it.
07

Compared with

Bollinger Bands. Bollinger Bands are the general tool and the squeeze is one reading of them. The squeeze adds the Keltner channel as the yardstick for narrow, and a histogram for direction, so it turns the width into a trigger.

Keltner Channels. The Keltner channel supplies the ATR-based reference in the squeeze. On its own it is a breakout and pullback tool; inside the squeeze it is the measure of normal range that the Bollinger Bands have to fall beneath.

Breakout. A breakout is price leaving a range. The squeeze is a way of finding ranges worth waiting for, defined by volatility rather than by price levels, and it fires on the change of regime rather than on the break of a level.

Average True Range. ATR is a volatility measure in price units with no regime attached. The squeeze compares an ATR channel with a deviation band to find a compression, and ATR then sets the stop beyond the squeeze range once the release comes.

08

Build it in Quant

Type one of these in the Quant desk, or click it. A request that fits a checked template is assembled on the spot without a credit; anything beyond the blanks goes to the copilot, which edits on top of the checked script.

Open Volatility Squeeze on the workbench chart
Drawn on real data; then audit, backtest and refine in conversation.
Open in Quant →
09

Questions

  • What exactly is the squeeze condition?

    The upper Bollinger Band below the upper Keltner line and the lower Bollinger Band above the lower Keltner line, both at once. In other words the 2-deviation bands sit entirely inside the 1.5 ATR channel of the same length. The library script shows this as amber dots on the zero line of the pane, and the Bollinger template tints its fill amber for the same bars.

  • How long does a squeeze last?

    Anything from 2 bars to several weeks on a daily chart. There is no fixed length, and long squeezes are the more interesting ones because the compression has lasted through more news. The script does not filter by length, so count the amber dots yourself and give more weight to the releases that end long squeezes.

  • Which direction will the release go?

    The squeeze itself does not know. The histogram is the direction read: above zero at the release means price has been drifting above its recent centre and the script marks a long; below zero marks a short. It is a tilt, not a certainty, and releases against the higher-timeframe trend fail more often.

  • What does the histogram measure?

    The drift of the close away from a centre made of the 20-bar range midpoint and the 20-bar average, smoothed with a linear regression. Positive means price has been holding above that centre, negative below. The colour compares each bar with the last: bright while the value grows, faded while it shrinks.

  • Why did the release fail?

    Because a change of volatility regime is not a promise of a trend. Some releases are one wide bar of news that reverses, some come with a flat histogram and no side, and some fight the higher-timeframe trend. A stop beyond the squeeze range keeps the failure small, and the long squeezes with bright histograms fail least.

  • Which timeframe should I read it on?

    Daily and 4-hour charts give the cleanest squeezes, with compressions lasting days and releases that run. 1-hour charts work on liquid futures and crypto. On 1 to 5-minute charts the squeeze fires many times a day and most releases are noise, so use it there only as context for a higher-timeframe compression.