Bollinger Bands: Formula, Signals, and What Tests Reveal

Closing prices shown with their 20-period middle, upper, and lower Bollinger Bands.

Key takeaways

  • Bollinger Bands place boundaries based on price spread around a moving average; a band touch alone is not a trading signal.
  • With population standard deviation calculated from the same window including the current close, a close strictly outside two-standard-deviation bands is impossible with five or fewer closes.
  • A longer lookback can first increase and then reduce activity; an old price leaving can sharply narrow the bands. Historical activity patterns do not establish profitable signals.

Bollinger Bands place an upper and lower band around a moving average. The bands widen when the prices in their calculation become more spread out and narrow when those prices become more similar.

Traders use them to read relative high and low prices, watch volatility, and define trading rules. Across 226,064 configuration evaluations, a longer lookback could produce more trades, while extending it further could reduce the count again. The current price also helps determine the boundary it is trying to cross.

What do Bollinger Bands show?

The middle line is usually a simple moving average. The outer lines sit a chosen number of standard deviations above and below it. Standard deviation measures how far the prices in the window spread around their average.

The familiar setting is 20 periods and two standard deviations, often written 20/2. Twenty periods means twenty candles: it covers different amounts of time on a two-hour chart and a daily chart. These are defaults, not universally best settings. Fidelity’s guide explains the conventional construction.

A high price relative to its recent window may be close to the upper band. A relatively low one may be close to the lower band. Neither description tells us whether the next move will continue or reverse.

%b expresses that relative position as (close − lower band) ÷ (upper band − lower band). When the width is nonzero, 0 is the lower band and 1 is the upper band; values outside 0–1 lie outside the bands.

How to calculate Bollinger Bands

For a lookback of N closing prices and a multiplier of k:

Middle band = SMA of the last N closes
Upper band  = middle band + k × standard deviation
Lower band  = middle band − k × standard deviation

Here we use population standard deviation: average the squared distances from the window’s mean, then take the square root. The current close belongs to that window.

For example, four closes of 100 followed by 110 have an average of 102 and a standard deviation of 4. With a multiplier of two, the upper band is 110 and the lower band is 94. The newest price has reached the upper band exactly.

The calculation uses the levels of the closing prices, rather than the standard deviation of percentage returns. Keeping that distinction clear helps explain why a steady trend can also create wide bands.

Common Bollinger Band signals

There are several familiar ways to use the same lines:

  • A breakout rule follows strength beyond the upper band, looking for continuation.
  • A fade rule buys weakness below the lower band, looking for a return toward the average.
  • A recovery rule waits for the close to return above the current lower band before buying.
  • A squeeze describes unusually narrow bands. Traders then watch for a subsequent move and its direction.

The bands also move, so returning above a lower band need not mean the close rose from the previous candle. A touch made by a candle’s high or low also differs from a close outside a band.

John Bollinger explicitly warns that a band tag alone is not a buy or sell signal. Prices can keep moving along a band during a trend. The use of two standard deviations also does not promise that 95% of future prices will remain inside.

Why a longer lookback can produce more activity

With the bands fixed at two standard deviations, one breakout comparison produced 452 executions at six closes, 608 at ten, and 432 at twenty. Extending the lookback first made the rule more active, then quieter. The same rise-then-fall pattern repeated across the studied samples for both breakout and fade rules.

Here, breakout means buying above the upper band and exiting below the middle line. Each buy or sell counts as one execution. The curve is not a count of every candle outside a band.

Recorded backtest metrics A longer lookback can produce more executions

Changing only the lookback can first increase executions, then reduce them. The multiplier and breakout rule stay fixed.

The value table below is available without JavaScript.

Chart data
Data and calculation details
This view selects a representative example; the chart-data download retains the full comparison. Source: Completed TrainBard backtests. Each point is one lookback setting with multiplier 2 and the breakout rule. The chart focuses on lengths 2–40; the evidence file retains all lengths 2–200. Points share prices and trades. Both panels use 2h candles; the table also checks 4h candles. Counts are individual buys and sells, not completed round trips. The script explicitly disables entries at k² ≥ N−1; the zeroes at N = 2 through N = 5 are enforced by that guard.
Accessible value table (39 observations)
ObservationRecorded executions · Breakout rule · 2σ
N = 20.000
N = 30.000
N = 40.000
N = 50.000
N = 6452.000
N = 7570.000
N = 8602.000
N = 9646.000
N = 10608.000
N = 11585.000
N = 12545.000
N = 13535.000
N = 14509.000
N = 15484.000
N = 16458.000
N = 17460.000
N = 18458.000
N = 19442.000
N = 20432.000
N = 21428.000
N = 22412.000
N = 23402.000
N = 24388.000
N = 25392.000
N = 26376.000
N = 27354.000
N = 28336.000
N = 29336.000
N = 30328.000
N = 31318.000
N = 32310.000
N = 33304.000
N = 34290.000
N = 35284.000
N = 36278.000
N = 37266.000
N = 38256.000
N = 39244.000
N = 40240.000

These comparisons hold the multiplier and trading rule fixed while changing the lookback. They measure rule activity, rather than the quality of the resulting trades.

The interaction between length and width is established. Bollinger’s own rules suggest changing the multiplier when the average length changes if the goal is similar price containment. Holding it fixed here lets us measure how a lookback change affects these exact trading rules.

The band’s lookback changes both its center and its width. A longer window can make an outside close easier to achieve near the short-window boundary, while also changing how long an existing position lasts. The formula alone does not predict the resulting execution count.

Changing the entry rule changes the comparison again. Buying above the upper band and buying below the lower band are separate strategies, even when both use the familiar 20/2 display. Their default-setting results and broader summaries are retained with the evidence; none of these activity comparisons establishes a profitable rule.

Why very short bands can stop signaling

The latest close helps determine the boundary it is trying to cross. As that price moves away from the other closes, it pulls the average toward itself and increases the standard deviation.

Constructed teaching example The same price can be inside one band and outside another

The latest close stays at 110 as the lookback changes. At five closes the two-standard-deviation upper band exactly meets 110; at six it falls below it.

The value table below is available without JavaScript.

Chart data
Data and calculation details
Source: Constructed calculation: N−1 closes of 100 and one close of 110. Each point is a separate window length, not historical prices or a trade result. Population standard deviation includes the current close. Constructed values illustrate the calculation; they are not market history or backtest results.
Accessible value table (24 observations)
ObservationSame latest close, different window length · Latest closeSame latest close, different window length · Middle SMASame latest close, different window length · Upper band (2σ)
N = 2110.000105.000115.000
N = 3110.000103.333112.761
N = 4110.000102.500111.160
N = 5110.000102.000110.000
N = 6110.000101.667109.120
N = 7110.000101.429108.427
N = 8110.000101.250107.864
N = 9110.000101.111107.397
N = 10110.000101.000107.000
N = 11110.000100.909106.659
N = 12110.000100.833106.361
N = 13110.000100.769106.099
N = 14110.000100.714105.865
N = 15110.000100.667105.656
N = 16110.000100.625105.466
N = 17110.000100.588105.294
N = 18110.000100.556105.137
N = 19110.000100.526104.992
N = 20110.000100.500104.859
N = 21110.000100.476104.735
N = 22110.000100.455104.621
N = 23110.000100.435104.513
N = 24110.000100.417104.413
N = 25110.000100.400104.319

Each point above is a separate constructed calculation. Keep the latest close at 110 and the older closes at 100, then change the number of closes in the window.

With five closes, 110 lies exactly on the two-standard-deviation upper band. With six, the upper band is about 109.12, so 110 is outside it. The latest price has not changed; its influence on the calculation has.

There is an exact limit behind this example:

Largest possible distance from the mean, in standard deviations
= square root of (N − 1)

For three closes that limit is about 1.41. For five it is 2. A rule requiring a close strictly beyond a two-standard-deviation band therefore cannot trigger with five or fewer closes.

This is established finite-sample geometry, related to Samuelson’s inequality. It applies when the same window, including the current close, supplies both the average and population standard deviation. It does not impose this limit on a candle’s high against close-based bands, or on a new price compared with yesterday’s bands.

With six closes, a two-standard-deviation crossing becomes possible. Possibility still tells us nothing about its frequency or profitability.

Why bands can narrow while the latest price barely changes

Every new close adds one price to the window and removes another. Sometimes the price leaving matters much more than the latest change.

Historical indicator values A quiet new close, a large change in band width

Twenty-close Bollinger Bands at two population standard deviations. Watch the band width shrink as an older high close leaves the window.

The value table below is available without JavaScript.

Chart data
Data and calculation details
Source: Official Binance Spot monthly klines, December 2025. Band values calculated locally from official closing prices; no execution markers. Each x label is the candle's opening time in UTC, and its close is known two hours later. This excerpt was selected to illustrate a large change in window dispersion.
Accessible value table (84 observations)
ObservationClosing price and 20/2 bands · CloseClosing price and 20/2 bands · 20-period SMAClosing price and 20/2 bands · Upper band (2σ)Closing price and 20/2 bands · Lower band (2σ)BandWidth (%) · BandWidth
2025-12-11T00:00:00Z90,674.74092,311.25494,125.03090,497.4783.930
2025-12-11T02:00:00Z89,880.01092,286.02794,216.56890,355.4864.184
2025-12-11T04:00:00Z90,316.72092,280.31294,233.33290,327.2914.233
2025-12-11T06:00:00Z90,272.75092,158.57494,285.67790,031.4704.616
2025-12-11T08:00:00Z90,234.19091,974.38494,098.15589,850.6124.618
2025-12-11T10:00:00Z90,242.35091,796.46093,874.09989,718.8204.527
2025-12-11T12:00:00Z90,103.53091,669.63693,833.69289,505.5804.721
2025-12-11T14:00:00Z89,872.51091,529.32293,775.79389,282.8504.909
2025-12-11T16:00:00Z89,983.23091,412.66593,724.89289,100.4385.059
2025-12-11T18:00:00Z90,839.81091,334.12593,611.88089,056.3694.988
2025-12-11T20:00:00Z92,858.39091,349.23093,662.92989,035.5315.066
2025-12-11T22:00:00Z92,513.38091,335.75493,618.83089,052.6774.999
2025-12-12T00:00:00Z92,170.00091,298.25393,499.16989,097.3374.821
2025-12-12T02:00:00Z92,283.40091,306.40193,520.59789,092.2044.850
2025-12-12T04:00:00Z92,444.42091,323.93993,568.15389,079.7244.915
2025-12-12T06:00:00Z92,425.34091,342.02193,615.42489,068.6184.978
2025-12-12T08:00:00Z92,520.56091,348.23893,633.78589,062.6905.004
2025-12-12T10:00:00Z92,418.19091,321.26493,542.01189,100.5164.864
2025-12-12T12:00:00Z92,302.79091,318.58493,534.45389,102.7154.853
2025-12-12T14:00:00Z89,935.14091,214.57393,484.48188,944.6644.977
2025-12-12T16:00:00Z90,083.09091,184.99093,497.29488,872.6865.072
2025-12-12T18:00:00Z90,198.22091,200.90193,481.22788,920.5745.001
2025-12-12T20:00:00Z90,193.94091,194.76293,485.21588,904.3085.023
2025-12-12T22:00:00Z90,268.42091,194.54593,485.34788,903.7435.024
2025-12-13T00:00:00Z90,229.91091,194.33193,485.49388,903.1695.025
2025-12-13T02:00:00Z90,345.54091,199.49193,482.50488,916.4775.007
2025-12-13T04:00:00Z90,342.91091,211.46093,473.78188,949.1384.961
2025-12-13T06:00:00Z90,329.97091,234.33393,450.82989,017.8364.859
2025-12-13T08:00:00Z90,422.57091,256.30093,431.07989,081.5204.766
2025-12-13T10:00:00Z90,330.36091,230.82793,436.24189,025.4134.835
2025-12-13T12:00:00Z90,245.87091,100.20193,212.03388,988.3694.636
2025-12-13T14:00:00Z90,092.16090,979.14093,029.75688,928.5244.508
2025-12-13T16:00:00Z90,052.61090,873.27192,885.29888,861.2434.428
2025-12-13T18:00:00Z90,178.16090,768.00992,692.29488,843.7234.240
2025-12-13T20:00:00Z90,175.97090,654.58692,432.06988,877.1033.921
2025-12-13T22:00:00Z90,240.01090,545.32092,132.44088,958.1993.506
2025-12-14T00:00:00Z90,293.29090,433.95691,738.46189,129.4512.885
2025-12-14T02:00:00Z90,258.98090,325.99691,260.76789,391.2242.070
2025-12-14T04:00:00Z90,199.06090,220.80990,447.12689,994.4920.502
2025-12-14T06:00:00Z90,245.60090,236.33290,420.87890,051.7860.409
2025-12-14T08:00:00Z90,020.06090,233.18190,429.84290,036.5190.436
2025-12-14T10:00:00Z89,360.00090,191.27090,620.09889,762.4410.951
2025-12-14T12:00:00Z89,489.50090,156.04890,682.76089,629.3351.168
2025-12-14T14:00:00Z89,022.91090,093.77290,812.23489,375.3101.595
2025-12-14T16:00:00Z88,810.67090,022.81090,929.23689,116.3842.014
2025-12-14T18:00:00Z88,644.88089,937.77791,010.90088,864.6542.386
2025-12-14T20:00:00Z88,443.85089,842.82491,079.37888,606.2702.753
2025-12-14T22:00:00Z88,172.17089,734.93491,146.76388,323.1053.147
2025-12-15T00:00:00Z89,242.32089,675.92291,066.35188,285.4923.101
2025-12-15T02:00:00Z89,282.60089,623.53490,990.13588,256.9323.050
2025-12-15T04:00:00Z89,615.24089,592.00290,928.48188,255.5232.983
2025-12-15T06:00:00Z89,753.42089,575.06590,894.23488,255.8962.945
2025-12-15T08:00:00Z89,865.12089,565.69190,873.77088,257.6112.921
2025-12-15T10:00:00Z89,641.28089,538.84790,817.24888,260.4452.856
2025-12-15T12:00:00Z89,432.00089,501.64890,746.58788,256.7092.782
2025-12-15T14:00:00Z87,033.22089,341.30990,940.25587,742.3623.579
2025-12-15T16:00:00Z85,762.87089,114.78891,289.91386,939.6624.882
2025-12-15T18:00:00Z86,149.96088,909.33791,370.74686,447.9275.537
2025-12-15T20:00:00Z86,243.78088,711.57391,355.52086,067.6255.961
2025-12-15T22:00:00Z86,432.08088,520.89791,243.68885,798.1056.152
2025-12-16T00:00:00Z85,891.02088,314.44591,173.96585,454.9246.476
2025-12-16T02:00:00Z85,875.92088,140.24191,144.59085,135.8916.817
2025-12-16T04:00:00Z86,028.11087,967.17191,038.72184,895.6216.983
2025-12-16T06:00:00Z86,021.51087,817.10190,960.11584,674.0877.158
2025-12-16T08:00:00Z86,350.00087,694.06890,864.40384,523.7327.230
2025-12-16T10:00:00Z87,261.45087,624.89690,769.49784,480.2957.177
2025-12-16T12:00:00Z86,443.02087,524.85590,686.13784,363.5727.224
2025-12-16T14:00:00Z87,977.43087,515.11890,669.55884,360.6777.209
2025-12-16T16:00:00Z87,131.99087,409.60190,465.52584,353.6776.992
2025-12-16T18:00:00Z87,585.77087,324.76090,259.79984,389.7206.722
2025-12-16T20:00:00Z87,768.59087,232.42789,983.88084,480.9746.308
2025-12-16T22:00:00Z87,863.42087,137.92789,656.52284,619.3325.781
2025-12-17T00:00:00Z87,552.30087,022.28689,221.52684,823.0465.054
2025-12-17T02:00:00Z87,213.59086,900.90288,748.39085,053.4134.252
2025-12-17T04:00:00Z86,626.39086,760.62188,198.77285,322.4703.315
2025-12-17T06:00:00Z87,045.59086,761.24088,199.86985,322.6103.316
2025-12-17T08:00:00Z86,417.46086,793.96988,168.61885,419.3203.168
2025-12-17T10:00:00Z86,983.26086,835.63488,179.85685,491.4123.096
2025-12-17T12:00:00Z87,631.37086,905.01488,263.04885,546.9793.125
2025-12-17T14:00:00Z87,233.44086,945.08288,292.18185,597.9823.099
2025-12-17T16:00:00Z86,427.12086,971.88788,253.78085,689.9932.948
2025-12-17T18:00:00Z86,018.53086,979.01788,237.82485,720.2102.895
2025-12-17T20:00:00Z85,982.88086,976.75688,242.53185,710.9802.911
2025-12-17T22:00:00Z86,243.22086,987.84188,223.48485,752.1982.841

Select The older high remains in the window, then A small price change, much narrower bands. The close falls by about 0.07%, while BandWidth narrows from 2.07% to 0.50% as an older high leaves the twenty-close window.

BandWidth is the distance between the outer bands divided by the middle band, expressed here as a percentage. The chart shows the changing indicator values without execution markers.

The window has become much more compact. That is useful information, but a sudden narrowing does not by itself establish a new change in the market’s direction. Bollinger’s own rules already describe this window effect; the example makes its arithmetic visible.

How we checked the behavior

The 226,064 main configuration evaluations varied lookback and band width for breakout and fade rules. The full settings, sources, and paired comparisons are recorded below.

Settings, accounting, and reproducibility

The study covered Binance Spot Bitcoin and Ether, two- and four-hour candles, and the historical windows 2021–2023 and 2024–2025. These are the eight datasets used for replication.

The activity chart foregrounds the Bitcoin two-hour 2021–2023 breakout curve: this is the 452→608→432 example in the text. The complete chart-data download retains both markets and periods: its panels are Bitcoin then Ether, both on two-hour candles; within each panel, the first curve is 2021–2023 and the second is 2024–2025. The periods cover different amounts of calendar time, so comparisons concern changes within each curve.

DatasetLength 6Length 10Length 20
BTC · 2h · 2021–2023452608432
BTC · 2h · 2024–2025256391310
BTC · 4h · 2021–2023230294186
BTC · 4h · 2024–2025142214138
ETH · 2h · 2021–2023462608408
ETH · 2h · 2024–2025300404298
ETH · 4h · 2021–2023224254200
ETH · 4h · 2024–2025162202148

Both breakout and fade rules increased executions from six to ten closes, then reduced them from ten to twenty, in all eight datasets. All sixteen rule-and-dataset comparisons remain in the measurement file.

Each frame used the same frozen grid: every lookback from 2 through 200; multipliers from 0.5 through 4 in steps of 0.05; and two entry rules. That is 28,258 valid configurations per frame. The two candle sizes were grouped into four completed batches of 56,516 evaluations.

Each evaluation started with 10,000 USDT and used no leverage. A long entry used a 99% equity budget, leaving a 1% cash reserve for next-open price changes. The combined fee/slippage setting was 0.1% per execution. The first 500 bars of each selected window were startup bars in cash. Larger candles therefore use more elapsed startup time as well as more time in each lookback. Idle cash earned no yield. Any remaining position was valued at the final close.

The breakout rule entered when the close was above the upper band and exited below the middle line. The fade rule entered below the lower band and exited at or above the middle. These conditions were checked at candle closes. The script requested next-bar market execution.

The script closes only an existing position and enters only while flat. These two rule families cannot ask for entry and exit on the same close.

The selected date endpoints run from 00:00 UTC on the start date through the candle opening at 00:00 UTC on the end date. They do not include the rest of the final calendar day. The platform full-window holding figure is the price return from the first close to the last close, before costs. The tested rules remain in cash through startup. Separate passive controls buy once after the same startup, with the same 99% allocation and entry cost, then hold. The evidence reports both all valid configurations and traded configurations above those controls: a zero-trade cash outcome can beat a negative passive return without trading.

Profit also needs a reference point. Across the later Bitcoin datasets, 44,030 of 56,516 configurations finished above their initial cash. 5,849 beat a passive control with the same 500-bar startup, 99% allocation, and entry cost; none beat the platform’s full-window buy-and-hold return. The full-window comparator starts at the first close. Changing when holding begins materially changes the comparison. These counts describe related historical settings; they do not validate an edge on new data.

The script explicitly prevents entries when k² is greater than or equal to N−1. That guard enforces the mathematical limit and avoids numerical boundary artefacts. Those configurations remain valid cash outcomes in the accounting. Their zero trades are not independent empirical confirmation of the identity.

The completed batches contain 219,088 exported traded rows and 6,976 valid settings with zero trades omitted from the exports. Joint batch totals and zero-trade counts were reconciled before splitting the candle sizes. Exact parameter tuples, including candle size, were checked for duplicate or conflicting rows. The guard accounts for 802 structurally inactive settings per frame; additional feasible settings can also have no trades in a selected historical window.

Preparatory boundary checks and execution diagnostics are retained in the research archive and excluded from the main evaluation count. Raw files and script versions are identified by SHA-256 checksums.

A separate trace check compared all 594 recorded executions from the Bitcoin two-hour 20/2 controls with official Binance next-open prices and the preceding-close signal conditions. All 594 matched the official open price to display precision and had the appropriate preceding-close condition.

These are related configuration evaluations sharing prices and many trades, not independent statistical trials. The later historical window checks the same grid; it is not prospective testing. Adjacent settings and replication help describe the behavior without establishing an edge in untested markets.

The historical window-memory example uses official Binance Spot BTCUSDT two-hour candles from 11–17 December 2025. Its indicator values were calculated locally. The selected adjacent closes move by less than 0.1%; the example illustrates window composition rather than a representative event frequency. The exact source, timestamps, values, and selection method remain in its candle provenance.

The tested Pine script, measurement and provenance file, and completed batch screenshot accompany the article. The historical chart has its own candle provenance. Original exports, diagnostic checks, and checksums remain in the research archive.

To explore the same effect, open TrainBard with the supplied script. Hold the multiplier and rule fixed while changing the lookback. Then keep the bands fixed and compare the entry rules: the indicator supplies the boundaries, while the rule determines the decisions.

For another measure of volatility, see our ATR guide. Related indicator guides cover the simple moving average, RSI, and MACD.