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
How I test the setup
- 1
When I review SPY daily bars, I calculate BandWidth instead of judging the gap between bands by eye.
- 2
I compare SPY, QQQ, and AAPL with one fixed 20-bar rule before changing the length or multiplier.
- 3
I wait for the bar to close before recording a breakout. An intrabar move can reverse before the candle is complete.
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 standard deviation with ATR.
- 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.
A squeeze does not choose the breakout direction
Compression can end with an upward break, a downward break, or more sideways trading. A testable breakout rule can wait for a bar to close outside an outer band after the squeeze ends. 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
| Question | Relative BandWidth | BB inside Keltner |
|---|---|---|
| What it compares | Current width with the same chart history | Standard deviation width with ATR width |
| Extra indicator | None | Keltner Channel |
| Example input | Lowest 10% over 120 bars | 20 EMA with a 1.5 ATR channel |
| Direction signal | None | None |
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 Bollinger Bands at 2 standard deviations and a 20-bar EMA Keltner Channel at 1.5 ATR. Mark a squeeze only when the upper Bollinger Band is below the upper Keltner Channel and the lower Bollinger Band is above the lower Keltner Channel. Mark the release on the first bar after that condition ends. Add separate bar-close alerts for a close above the upper Bollinger Band and below the lower Bollinger Band. Do not label either direction as a prediction.Build the squeeze rule
Related Bollinger Bands pages
Tools for the next test
Keltner Channel vs Bollinger Bands
Compare ATR-based Keltner Channels with standard-deviation Bollinger Bands using explicit formulas and fixed test assumptions.
HMA Bollinger Bands
Replace the standard Bollinger basis with a Hull Moving Average, compare the response, and generate a testable Pine Script rule.
Bollinger Bands Calculator
Compute Bollinger Bands to analyze market volatility and potential price breakouts.
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.