Volatility compression

Bollinger Band Squeeze: define compression before testing a breakout

A Bollinger Band squeeze is a period when the bands narrow as measured volatility falls. It identifies compression. It does not tell you whether the next move will be up or down.

Direct answer

Start with 20-bar Bollinger Bands at two standard deviations, then define squeeze conditions with either relative BandWidth or Bollinger Bands inside a Keltner Channel. Record the definition before testing because the two methods do not produce identical signals.

Starting values

Typical length

20 bars

Band distance

2 standard deviations

Compression measure

BandWidth or BB inside KC

Direction forecast

None by itself

Checks before using the result

  1. 1

    Record normalized BandWidth numerically; visual spacing changes with chart scale. Keep its positive basis and price convention consistent.

  2. 2

    Compare the same rule across a prespecified symbol set before selecting parameters. Keep dates, sessions and data adjustments consistent.

  3. 3

    Record signals at the defined bar close. A developing candle can move outside a band and return inside before completion.

Bollinger Band squeeze formula

Standard Bollinger Bands use a 20-bar simple moving average as the basis. The upper and lower bands sit two standard deviations from that basis. BandWidth turns the distance into a comparable percentage, which makes compression measurable instead of visual.

  • Basis = 20-bar simple moving average of close.
  • Upper band = basis + 2 x standard deviation.
  • Lower band = basis - 2 x standard deviation.
  • BandWidth = (upper band - lower band) / basis x 100.

Two squeeze definitions that should stay separate

A relative BandWidth rule compares current width with the same symbol and timeframe. For example, you can mark values in the lowest 10% of the previous 120 bars. A second method marks a squeeze when both Bollinger Bands sit inside a Keltner Channel. The first rule uses Bollinger history. The second compares complete channel boundaries, including different SMA and EMA centers; a narrower BB width alone is insufficient.

  • Relative BandWidth answers whether the current bands are narrow for this chart.
  • Bollinger Bands inside Keltner Channels compares two volatility formulas.
  • The 10% rank and 120-bar lookback are test inputs, not universal settings.

Check the boundaries with a synthetic example

With BB basis 100 and deviation 1 at multiplier 2, the bands are 98 and 102 and BandWidth is 4%. A KC centered at 100 with ATR 2 and multiplier 1.5 spans 97 to 103: both strict containment tests pass. Move only the KC center to 104 and its range becomes 101 to 107. Its width is still 6 versus BB width 4, but the BB lower bound 98 is outside. Width comparison alone would give the wrong result. Equality with either boundary does not pass the strict rule below. A zero BB basis makes normalized width undefined.

A squeeze does not choose the breakout direction

Compression can end with an upward break, a downward break, or more sideways trading. A testable rule can require the first non-squeeze bar after a squeeze to close outside an outer band. Waiting for a later breakout instead requires an explicit arming window and expiry. Volume above its 20-bar average can be recorded as a separate filter. Do not add several filters at once or you will not know which one changed the result.

How to test the rule without hiding the assumptions

Use fixed dates, bar-close signals, fees, slippage, exits, and position sizing. Compare the same rule on SPY, QQQ, and AAPL before changing parameters. Keep out-of-sample dates separate from the period used to choose settings. A result on historical bars is not a promise about live trading.

Relative BandWidth vs Bollinger Bands inside Keltner Channels

QuestionRelative BandWidthBB inside Keltner
What it comparesCurrent width with the same chart historyBoth boundaries, including center displacement
Extra indicatorNoneKeltner Channel
Example inputLowest 10% over 120 bars20 EMA with a 1.5 ATR channel
Direction signalNoneNone

Bollinger Band squeeze Pine Script prompt

This prompt keeps the squeeze definition, release event, and direction rule visible.

Create a Pine Script v6 indicator with 20-bar close SMA Bollinger Bands at 2 population standard deviations and a 20-bar close EMA Keltner Channel at 1.5 times Wilder ATR(20). Require complete valid calculation windows. Mark a squeeze only when upper BB < upper KC and lower BB > lower KC; equality is not inside. Mark release only on a confirmed bar when the previous valid bar was inside and the current bar is not. On that same release bar, alert separately if close > current upper BB or close < current lower BB. Do not keep alerts armed on later bars. Do not use future values or label either direction as a prediction. Include no trade orders.
Build the squeeze rule

Pineify is an information tool, not investment advice. A squeeze does not guarantee a breakout or profitable trade. Historical results can fail in live markets.

Common questions