Bollinger Bands Calculator
Calculate the middle, upper and lower bands from a price series, with bandwidth and %B reported alongside.
Bollinger bands are a moving average with an envelope drawn a chosen number of standard deviations either side of it, which is why they are also described plainly as standard deviation bands. In this Bollinger bands calculator the middle band is the simple average of the last n closes, the standard deviation is measured over exactly the same n closes, and the outer bands sit k of those deviations above and below. Because the envelope is scaled by the window's own variability, the bands widen after prices have been moving about and narrow after they have not.
Formula: upper band = SMA + (k x standard deviation), lower band = SMA - (k x standard deviation)
Your figures
How many closes the middle band averages, and the same window the deviation is measured over. The series below holds 24 closes, so any period from 2 to 24 works as it stands.
How far either side of the middle band to place the outer ones. Bollinger's own bands use 2.
Population is Bollinger's own definition and what charts plot. Sample is the convention performance statistics use, and gives bands roughly 2.6% wider on a 20-period window.
Results
Bollinger bands
99.9482 – 105.4018
middle band 102.6750, 2.00 standard deviations either side of it
- Upper bandMiddle band plus 2.00 × the standard deviation of the window.
- 105.4018
- Middle bandThe simple moving average of the last 20 closes.
- 102.6750
- Lower bandMiddle band less 2.00 × the same standard deviation.
- 99.9482
- Latest closeThe final close in the series. Every band is measured to the window ending there.
- 104.4000
- %B(close − lower) ÷ (upper − lower). It reads 0 on the lower band and 1 on the upper, and runs past either end when the close is outside them.
- 0.8163
- BandwidthThe spread between the bands as a percentage of the middle one, which is how the width of two different instruments is compared.
- 5.312%
- Band spreadUpper less lower, in price units. The bands are symmetric about the middle one, so this is twice the offset applied to either side.
- 5.4536
- Standard deviation of the windowMeasured on the same closes the middle band averages, before the multiplier is applied.
- 1.3634
- Deviation conventionBollinger's own definition, and what charting packages plot.
- Population (÷ n)
- Closes usedEvery row entered held a close.
- 24
- Bar 20Close 102.9000 · upper 104.3329 · middle 101.8900 · lower 99.4471
- 0.7067
- Bar 21Close 103.8000 · upper 104.4963 · middle 102.0800 · lower 99.6637
- 0.8559
- Bar 22Close 104.6000 · upper 104.8315 · middle 102.2800 · lower 99.7285
- 0.9546
- Bar 23Close 105.1000 · upper 105.2527 · middle 102.4750 · lower 99.6973
- 0.9725
- Bar 24Close 104.4000 · upper 105.4018 · middle 102.6750 · lower 99.9482
- 0.8163
What this means
Over the last 20 of the 24 closes entered, the simple average is 102.6750 and the population (÷ n) standard deviation of that same window is 1.3634. Placing 2.00 deviations either side puts the upper band at 105.4018 and the lower at 99.9482, a spread of 5.4536 — 5.312% of the middle band. The final close of 104.4000 gives a %B of 0.8163, which is simply where it falls on the line running from 0 at the lower band to 1 at the upper one.
- The bands are a distance from a mean, expressed in units of that window's own variability. That is why they widen after prices have been moving about and narrow after they have not, and why a close outside them is a statement about the window that has already printed rather than about the next bar.
- Bollinger specified the population standard deviation, dividing by n. The performance calculators on this site divide by n − 1 because they treat a record as a sample of a process. On a 20-period window that makes the sample figure about 2.6% larger, which moves a two-deviation band visibly. Both are offered and the one used is named in the result.
- %B has no value when the bands touch. A window whose closes are all identical has a deviation of zero, so there is no distance between the bands for a price to sit inside, and the figure is left blank rather than filled in.
- Every price here is one you entered. Nothing is fetched and no market, bar size or session is assumed, so the same calculation serves a five-minute chart, a daily chart and a column of weekly closes without knowing which it has been given.
- These are descriptions of arithmetic performed on prices that have already printed. Where the latest price sits relative to a line says nothing about where the next one will be.
Bollinger bands: 99.9482 – 105.4018
The link reopens this calculator with the same numbers. Nothing you enter is sent to a server.
Continue with these figures
About the Bollinger Bands calculation
The bands are a distance, not a threshold. A close outside them says the latest price is more than k standard deviations from the average of the window it belongs to — an arithmetic fact about closes that have already printed. It carries no implication about the next close, and nothing on this page treats a band as a boundary prices are expected to respect.
The most useful thing this page can tell you is which standard deviation it used. Bollinger specified the population form, dividing the sum of squared deviations by n, and that is what charting packages plot and what this calculator defaults to. The sample form, dividing by n − 1, is the convention every performance statistic elsewhere on this site uses. Neither is wrong; they answer different questions. On a 20-period window the sample figure is about 2.6% larger, enough to move a two-deviation band visibly, and both are offered here with the choice named in the result.
Alongside the three bands the page doubles as a percent B calculator and a Bollinger band width calculator. %B locates the latest close on the line running from 0 at the lower band to 1 at the upper one, and bandwidth expresses the spread between the bands as a percentage of the middle one, so instruments at very different price levels can be compared.
Bollinger Bands formula
n closes, oldest first, over one window
middle = (c_(i−n+1) + … + c_i) ÷ n
σ = √( Σ (c − middle)² ÷ d )
d = n population — Bollinger's own definition
d = n − 1 sample — the convention performance statistics use
upper = middle + k × σ
lower = middle − k × σ
band spread = upper − lower = 2 × k × σ
bandwidth = (upper − lower) ÷ middle
%B = (c_i − lower) ÷ (upper − lower)- n
- The period: how many closes the middle band averages, and the same window the standard deviation is measured over. Conventionally 20, and yours to change.
- k
- How many standard deviations each outer band sits from the middle one. Bollinger's own bands use 2, and the field accepts any positive multiplier up to 10.
- σ
- The standard deviation of the closes in the window: the root of the average squared distance from the middle band. It is what makes the envelope respond to the window's own variability.
- d
- The divisor inside the standard deviation — n for the population form, n − 1 for the sample form. This is the choice that most often separates two platforms' bands.
- %B
- Where the latest close falls between the bands, read as a coordinate: 0 on the lower band, 0.5 on the middle one, 1 on the upper, and beyond either end when the close is outside them.
- bandwidth
- The band spread divided by the middle band, usually quoted as a percentage. Dividing by the middle band is what makes the width comparable across instruments at different prices.
The envelope is scaled by the same window it is centred on, which is what separates these bands from a fixed-percentage channel. If the last twenty closes were tightly clustered, σ is small and the bands sit close to the average; if they were scattered, σ is large and the bands stand well back. The width is a statement about how much the closes in that window disagreed with their own mean, expressed in the price units of the instrument itself.
The choice of divisor is a genuine fork rather than a rounding detail. Dividing the sum of squares by n treats the window as the entire population being described. Dividing by n − 1 treats it as a sample drawn from something larger, correcting for the mean having been estimated from the same closes the deviations are taken from. The sample figure is always the larger, by a factor of √(n ÷ (n − 1)): about 2.6% on a twenty-period window and about 11.8% on a five-period one.
%B is a coordinate rather than a verdict, and it is not bounded. It reads 0.5 on the middle band, 1 on the upper band and 1.25 a quarter of the band spread above it, while negative values are ordinary and mean the close is below the lower band. Bandwidth answers a different question — how far apart the bands are as a proportion of the middle one — and exists because a spread of 8 points is enormous on something trading at 12 and negligible on something trading at 12,000.
One case has no answer and is reported as such. If every close in the window is identical, the standard deviation is exactly zero, both outer bands collapse onto the middle one and the spread between them is zero. There is then no distance for a price to sit inside, so %B has no value: the calculator flags the collapse and leaves the figure blank rather than dividing by zero and printing something that only looks like a number.
Bollinger Bands: a worked example
Six closes — 101, 100, 102, 104, 103 and 106 — with a five-bar middle band, bands two standard deviations either side, and the population convention.
- Middle band, last five closes(100 + 102 + 104 + 103 + 106) ÷ 5 = 515 ÷ 5 = 103.00
- Each close less the middle band−3, −1, +1, 0, +3
- Sum of squared deviations9 + 1 + 1 + 0 + 9 = 20
- Population standard deviation√(20 ÷ 5) = √4 = 2.0000
- Upper and lower bands103 + 2 × 2 = 107.00 and 103 − 2 × 2 = 99.00
- Band spread and bandwidth107 − 99 = 8.00, and 8 ÷ 103 = 7.767%
- %B for the closing price of 106(106 − 99) ÷ 8 = 7 ÷ 8 = 0.8750
Bands of 99.00 and 107.00 around a middle band of 103.00, with the 106 close reading 0.8750 on the %B scale — seven-eighths of the way from the lower band to the upper one. Switching the divisor to the sample form on the identical six closes gives √(20 ÷ 4) = 2.2361, bands of 98.5279 and 107.4721, and a %B of 0.8354. The prices did not change; only the convention did, and on a five-bar window that moved each band by nearly half a point.
How to use the Bollinger Bands calculator
- Enter your closes oldest first, one per row. Bollinger bands are defined on closing prices, though any single price per bar behaves the same way arithmetically, and blank rows are ignored rather than treated as zeros.
- Set the period. Twenty is the conventional default and the series opens with 24 closes behind it, so anything from 2 to 24 works without adding rows. It is an input rather than a constant: a shorter window turns more often and measures its deviation over fewer observations, which makes it noisier.
- Set the number of standard deviations. Two is Bollinger's own setting, and the field accepts anything above zero up to 10, so a narrower or wider envelope can be examined on the same closes.
- Choose the deviation convention deliberately rather than leaving it. Population matches charting packages and Bollinger's definition; sample matches the volatility and Sharpe calculators on this site. The result panel states which one produced the numbers in front of you.
- Read %B and bandwidth as two different questions, then scroll to the per-bar rows for the last eight windows. Each carries its own upper, middle and lower band against that bar's close, which is how the widening and narrowing of the envelope becomes visible rather than a single snapshot. Bandwidth contracting across those rows is what a Bollinger squeeze calculator is built to watch for, though ranking that contraction against a longer history is not something this page does for you.
Limitations of the Bollinger Bands calculator
Every calculation makes assumptions. These are the ones that matter here.
- The bands describe the window they are computed from and nothing outside it. Both the average and the deviation are recomputed on every bar, so a level that existed yesterday has already moved by today and was never a fixed line.
- The familiar claim that roughly 95% of prices fall inside two-deviation bands does not hold. The deviation is estimated from the very closes it is being compared against, and price series carry fatter tails than a normal distribution; Bollinger himself put the figure nearer 88–89%.
- A standard deviation estimated from twenty observations is a noisy quantity. Two adjacent windows of the same series routinely produce visibly different band widths without anything having changed in the instrument.
- The population and sample conventions give different bands from identical closes, so a figure from here is only comparable with another one built the same way. The gap is largest on exactly the short windows most easily checked by hand.
- Only the closes entered are used. A bar that traded far away from where it closed leaves no trace in the calculation, so the bands can be narrow across a window that contained large intraday movement.
- Neither a touch of a band nor a close outside one is treated here as a signal. These are levels computed from prices that have already printed, and reaching a level says nothing about whether it will hold.
Frequently asked questions about Bollinger Bands
Why do my platform's Bollinger bands differ from these?
Usually the standard deviation convention. Most charting packages use the population form that divides by n, following Bollinger's own definition, while statistical software and spreadsheets frequently default to the sample form that divides by n − 1 and produces slightly wider bands. Both are offered above. If the conventions match, check next that the period and the multiplier agree and that the platform is drawing on closes rather than on typical prices.
Can %B be negative or greater than one?
Yes, and routinely. %B is a coordinate on the line from the lower band to the upper one, not a percentage bounded at either end. A close below the lower band gives a negative value and a close above the upper band gives a value above one, with the magnitude telling you how far outside the envelope the price fell as a fraction of the band spread.
Is a close outside the bands a rare event?
Less rare than the two-standard-deviations label suggests. The deviation is measured over the same twenty closes the latest one is compared against, which makes the comparison self-referential, and real price series produce more extreme observations than a normal distribution allows. Closes fall outside two-deviation bands rather more often than a textbook 5% would imply, and one doing so describes that window rather than being an unusual event in itself.
Why is the %B figure sometimes blank?
Because the bands are touching. If every close in the window is the same number, the standard deviation is zero, the upper and lower bands both land on the middle one, and there is no distance between them for the price to sit inside. The calculation would be a division by zero, so the result flags the collapse and leaves the figure empty rather than reporting a value it cannot support.
Should the bands be built on closes or on typical prices?
Bollinger defined them on closes and that is the usual construction, which is why the field on this page asks for closes. Some implementations use the typical price, (high + low + close) ÷ 3, and will disagree with a close-based calculation on the same bars. The arithmetic is indifferent — it averages whatever single price per bar it is given — so the only requirement is knowing which one you supplied.
Last reviewed . See our methodology and editorial policy.
More technical calculators