Bollinger Squeeze Breakout (Breakout)

Bollinger's Squeeze: waits for the band width to hit a 125-bar low — the market coiling into unusual calm — then buys the first close above the upper band and sells when price falls back below the midline.

How It Works

  1. Compute 20-bar Bollinger Bands and watch their relative width — upper band minus lower band, divided by the middle. Narrow bands mean the market has gone unusually quiet.
  2. A squeeze is on when the width hits its lowest value of the last 125 bars: volatility is as compressed as it has been in roughly six months of bars, and quiet markets tend to resolve into violent moves.
  3. Buy the first close above the upper band within 5 bars of a squeeze — the compression resolving upward with force. A band break without a fresh squeeze is ignored.
  4. Sell when the close falls back below the middle band — the expansion has run its course.

Worked example. The bands narrow to 98.5–101.5 around a middle of 100 — a width of 3%, the lowest in 125 bars, so the squeeze is on. Two bars later price closes at 101.8, above the upper band — buy. The released move runs for weeks; when a close at 106.1 finally slips under the risen middle band at 106.5, the trade exits.

The Math Behind The Indicators

Everything runs on closing prices of the traded timeframe: P is a close, Pt today's close, and N counts bars — one bar is one candle of that timeframe, so 20 bars on a 1h chart is 20 hours.

Simple Moving Average (SMA)
The plain average of the last N closing prices: add them up, divide by N. It smooths out bar-to-bar noise so the underlying direction is easier to see — a rising SMA means recent prices sit above where they used to be.
2026-07-17T19:28:07.652959 image/svg+xml Matplotlib v3.11.0, https://matplotlib.org/
Example: With N = 3 and closes 100, 102, 104 the SMA is (100 + 102 + 104) / 3 = 102.
Bollinger Bands
A 20-bar SMA with an envelope two standard deviations above and below it. The standard deviation σ measures how far closes have recently strayed from their average, so the bands widen when the market is choppy and tighten when it is calm — a close outside a band is a statistically unusual move.
2026-07-17T19:28:07.664312 image/svg+xml Matplotlib v3.11.0, https://matplotlib.org/
Example: If the last 20 closes average 100 and typically stray about 1.5 from it (σ = 1.5), the bands sit at 100 ± 3, i.e. 97 and 103. A close at 96.5 is below the lower band — unusually cheap relative to the recent range.

Example Chart

Real Data — Score 20 / 100

Metrics Per Trade

Final Metrics

Scores

Resampled Data — Score 21 / 100

Metrics Per Trade

Final Metrics

Scores