Bollinger Bands: Calculate the Bands and Understand Their Limits

Table of Contents

    A stock closes near the top of its Bollinger Bands. Is that unusual for this stock, and is the price still trending up? The bands help you answer the first question by comparing today’s close with the stock’s recent prices. To answer the second, look at how the closes and bands have moved together across several bars.

    What Are Bollinger Bands?

    Bollinger Bands plot a moving average and two lines that sit an equal distance above and below it. John Bollinger’s traditional setting uses a 20-period simple moving average (SMA) with the outer bands set two population standard deviations from that average. The average and standard deviation use the same observations. Wider bands reflect greater spread in recent closing prices around their average. [1] [2]

    A period is one bar. On a daily stock chart, 20 periods means 20 trading closes. On a weekly chart, it means 20 weekly closes. The defaults are a starting point. A different bar interval, lookback or multiplier changes the reference used to judge the price. [2] [3]

    The Bollinger Bands Formula

    Take the latest 20 completed closing prices, including the current bar’s close. Call the oldest price P1 and the latest P20. Calculate the middle band M and the standard deviation σ from those 20 prices.

    Middle band and population standard deviation
    M = (P1 + … + P20) / 20
    σ = √{[(P1 − M)2 + … + (P20 − M)2] / 20}
    Average the closes. Then square each price’s distance from that average, average those squares and take the square root.
    Upper and lower bands
    Upper = M + 2 × σ
    Lower = M − 2 × σ
    The middle band, standard deviation and both outer bands are in the same units as price, such as dollars per share.

    The population convention treats the 20 observed closes as the full set for this calculation, so the divisor is 20. A sample standard deviation divides the same sum of squares by 19 and gives wider bands whenever the closes vary. When a fresh bar closes, add that price and remove the oldest close from both calculations. A large outlier leaving the window can change the bands even on a quiet day. [1] [2] [4]

    %B Measures Price Position and BandWidth Measures the Gap

    %B measures how far the latest close is from the lower band as a share of the full distance between the bands. BandWidth scales that distance by the middle band, which lets you compare the spread over time as the stock price changes. [2] [5] [6]

    Position as a ratio and width as a percentage
    %B = (Latest close − Lower) / (Upper − Lower)
    BandWidth (%) = 100 × (Upper − Lower) / M
    This article writes %B on the 0-to-1 scale, which extends below 0 and above 1. BandWidth is reported as a percentage of the middle band.

    A %B of 0 is exactly at the lower band, 0.50 is at the middle band and 1 is exactly at the upper band. A negative reading puts the close below the lower band. A reading above 1 puts it above the upper band. A reading of 0.75 places the close three-quarters of the way from the lower band to the upper band. That describes a price location and carries no probability. [5]

    At the default multiplier of 2, the full dollar gap is four standard deviations. If all 20 closes are equal and positive, BandWidth is 0% and %B is undefined because its denominator is zero. BandWidth itself is undefined if the middle band is zero.

    A 20-Period Bollinger Bands Example

    Consider a hypothetical stock with completed daily closes in U.S. dollars per share. Its first 20 closes, ending October 5, alternate between $96 and $104 in that order. Its next 20 closes alternate between $99 and $101, ending at $101 on November 2. Over the next four sessions, it closes at $104, $107, $110 and $113. Use a 20-period SMA and two population standard deviations throughout.

    Calculate the first window and the narrower window

    On October 5, ten closes at $96 and ten at $104 average (10 × 96 + 10 × 104) / 20 = $100. Every price is $4 from the mean. The standard deviation is √(20 × 42 / 20) = $4, which puts the bands at $92 and $108. The $104 close gives %B = (104 − 92) / (108 − 92) = 0.75. BandWidth is 100 × (108 − 92) / 100 = 16%.

    On November 2, ten closes at $99 and ten at $101 average (10 × 99 + 10 × 101) / 20 = $100. Each close is now $1 from the mean. The standard deviation is √(20 × 12 / 20) = $1, so the bands are $98 and $102. The $101 close gives %B = (101 − 98) / (102 − 98) = 0.75, while BandWidth falls to 100 × (102 − 98) / 100 = 4%. The two closes have the same relative position even though the later bands are much narrower.

    Roll the window one day forward

    On November 3, drop the oldest $99 close and add the new $104 close. The new mean is (2,000 − 99 + 104) / 20 = $100.25. The window contains nine $99 closes, ten $101 closes and one $104 close, so the variance is [9 × (99 − 100.25)2 + 10 × (101 − 100.25)2 + (104 − 100.25)2] / 20 = 1.6875. The standard deviation is about $1.2990.

    Subtract and add twice that standard deviation to $100.25. The bands are approximately $97.6519 and $102.8481. The gap is about $5.1962. Calculate %B ≈ (104 − 97.6519) / 5.1962 = 1.22 and BandWidth ≈ 100 × 5.1962 / 100.25 = 5.18%. The close is above the updated upper band. It helped determine the band before the comparison. The table rolls both calculations forward for each subsequent close. Results are rounded for display.

    Selected hypothetical daily results. Prices in USD per share.
    Date Close Lower SMA Upper %B BandWidth
    Oct. 5 104.00 92.00 100.00 108.00 0.75 16.00%
    Oct. 27 101.00 96.00 100.00 104.00 0.63 8.00%
    Nov. 2 101.00 98.00 100.00 102.00 0.75 4.00%
    Nov. 3 104.00 97.65 100.25 102.85 1.22 5.18%
    Nov. 4 107.00 96.63 100.55 104.47 1.32 7.80%
    Nov. 5 110.00 95.48 101.10 106.72 1.29 11.11%
    Nov. 6 113.00 94.06 101.70 109.34 1.24 15.03%

    How to Read a Squeeze and a Band Walk

    Compare the same stock in two parts of the example. Through November 2, the $99 and $101 closes replace the earlier $96 and $104 closes. After that, four rising closes enter the same 20-bar calculation. BandWidth tracks the gap between the bands relative to the average, and %B tells you where each close lands.

    Squeeze. On November 2, BandWidth is 4%, the lowest of the 21 readings available through that date. A squeeze is narrow relative to the same instrument’s history under the same settings. The creator’s screening service uses a six-month BandWidth low, one specific definition. The 4% reading in this short example is a teaching comparison and supplies neither the direction nor the timing of a breakout. A move beyond a band can also fade quickly. [2] [6] [7]

    Band walk. From November 3 through November 6, the closes and the upper band both rise. %B stays above 1 because every close exceeds its own upper band. In a falling trend, prices can likewise keep closing near or below the lower band. A touch or outside close alone gives insufficient evidence to trade a reversal. Consider repeated closes and the trend in the middle band. [2]

    Historical charts illustrate how context changes the reading. StockCharts documents repeated closes below the lower band in Monsanto (MON) from mid-January to early May 2010, an example of a downward band walk. In a weekly chart of Omega Healthcare Investors (OHI), John Bollinger points to a higher %B in October 2013 on a retest of the August low. The later low sat higher relative to its bands. Both are examples of how to read a chart. [1] [8]

    Bollinger Bands vs. ATR and Return Volatility

    Bollinger Bands compare a close with a moving price average and show the spread of recent closes around it. Average true range measures the size of recent bar ranges, taking the current high and low and the prior close into account. A large move within a day can raise true range even when the close sits close to recent closing prices.

    Standard deviation of returns describes how much period-to-period returns vary around their average. Bollinger Bands use the standard deviation of closing prices. Suppose a stock closes 1% higher each day. Every daily price return equals 1%, so every return is zero percentage points from the mean. Return standard deviation is zero. The closing prices vary across the 20 bars, so the upper and lower bands still have a positive gap.

    How to Reproduce the Bands in a Spreadsheet

    1. Use one completed close per row. Sort observations from oldest to newest on the same bar interval and closing-price basis. Keep the first 19 rows without bands. Check that each window contains 20 numeric closes.
    2. Use the same range for both calculations. In Excel, AVERAGE gives the middle band and STDEV.P gives the standard deviation using divisor 20. Roll both ranges one row at a time, then calculate the two bands, %B and BandWidth. For BandWidth, either format the width-to-middle ratio as a percentage or multiply it by 100 and display it with a percent sign. [4]
    3. Match inputs before comparing tools. Check the close field, completed bar and session, corporate-action adjustments, bar interval, SMA setting, window length, multiplier and any chart offset. Confirm the standard-deviation divisor before assuming an exact match. Keep extra precision until display. [3]

    MarketXLS documents running its Bollinger Bands analysis on closing prices supplied in Excel. If you use it to compare band values, align the input series and settings with your worksheet first. Its public feature documentation establishes a band-series workflow. Use the formulas above to calculate %B and BandWidth from the resulting bands. [9]

    Common Mistakes With Bollinger Bands

    • Using returns or an incomplete bar. Use closing price levels in both formulas. A live bar’s price and its bands can change before it closes.
    • Using the sample denominator. On November 2 in the example, dividing the squared-deviation sum of 20 by 19 gives √(20 / 19) ≈ $1.0260. That makes BandWidth about 4.10% instead of 4.00%.
    • Treating every touch as a reversal. Repeated touches or outside closes can occur in the direction of a trend. Check the sequence of closes and how the middle band moves.
    • Applying one squeeze threshold to every chart. Compare BandWidth with the same asset’s history using the same calculation and bar interval.

    Why Two Standard Deviations Give No 95% Forecast

    The normal-distribution rule describes a distribution with a specified mean and standard deviation. For that model, about 95% of probability lies within two standard deviations of the mean. Each Bollinger Band reading instead uses a new window of recent price levels. The current close helps set the boundaries against which it is measured, and the next window reuses 19 of the same closes. [2] [10]

    Counting how many past closes fell inside their contemporaneous bands describes that historical chart. To measure next-close coverage, freeze today’s bands before the next close arrives, then compare that future close with those fixed boundaries. That is a different measurement. The default band formula supplies no calibrated probability of future coverage, and the worked example supplies no evidence about trading performance.

    Frequently Asked Questions

    For a fixed alert based on the latest completed close, use that session’s band. The November 2 upper band of $102 was available before November 3. The final November 3 upper band of about $102.85 could only be calculated once the next close arrived.

    Yes. From November 4 to 5, the close rises from $107 to $110 while %B falls from 1.32 to 1.29. The price is still above the upper band, but the excess is smaller as a share of the wider band gap.

    Yes. When the middle band is positive, BandWidth falls if the middle band increases by a greater percentage than the gap. Compare the raw gap if the dollar distance matters and BandWidth if you want the distance relative to the moving average.

    Sources

    1. John Bollinger, A Complete Explanation of Bollinger Bands. Population calculation, defaults and dated chart case studies.
    2. John Bollinger, Bollinger Bands Rules. Traditional SMA, band walks, squeeze, relative price and statistical limits.
    3. TradingView, Bollinger Bands (BB). Price source, settings, offset and period conventions.
    4. Microsoft Support, STDEV.P and STDEV.S. Population and sample denominators.
    5. TradingView, Bollinger Bands %b. Position formula and boundary readings.
    6. TradingView, Bollinger BandWidth (BBW). Percentage scaling, relative width and failed breakouts.
    7. BollingerBands.us, Screening Documentation. Middle-band normalization and the service’s six-month squeeze screen.
    8. StockCharts ChartSchool, Bollinger Bands. Chart 7 shows lower-band closes during Monsanto’s 2010 downtrend.
    9. MarketXLS, Technical Indicators in Excel and Bollinger Bands Trading Strategy, August 26, 2017 for the latter. Analysis on supplied closes and the documented band-series workflow.
    10. NIST/SEMATECH e-Handbook of Statistical Methods, Normal Distribution. Normal probability model and its mean and scale parameters.

    Sources accessed December 2, 2026. The worked daily price series is hypothetical.

    Disclaimer

    This article is for educational and informational purposes only and does not constitute investment advice. The indicator settings and examples illustrate calculations and chart interpretation. They do not predict future prices or returns.