Bollinger Bands formula: how to calculate them (with Excel)
How the three Bollinger Bands are worked out — a 20-period average with bands two standard deviations above and below it — plus %B and bandwidth. With a worked example, the Excel formulas, a free Excel sheet and a box to calculate the bands from your own prices.
Last updated:
Needs: closing prices · Standard settings: Period 20 · Std dev multiplier 2
The Bollinger Bands formula
Middle band = SMA (20) of the close Std dev = √( Σ (Close − Middle band)² ÷ 20 ) over the same 20 closes Upper band = Middle band + 2 × Std dev Lower band = Middle band − 2 × Std dev %B = (Close − Lower band) ÷ (Upper band − Lower band) Bandwidth % = (Upper band − Lower band) ÷ Middle band × 100
The standard deviation divides by 20 (the “population” version, Excel's STDEVP), not 19. 20 and 2 are the usual settings; change them in the calculator below.
How to calculate Bollinger Bands step by step
- Average the last 20 closes for the middle band. The first full set is Day 1 to Day 20: middle band 1,018.39.
- Work out the standard deviation of the same 20 closes. Subtract the middle band from each close, square the differences, average them and take the square root: 32.60.
- Add and subtract twice the standard deviation. Upper band = 1,018.39 + 2 × 32.60 = 1,083.59; lower band = 1,018.39 − 2 × 32.60 = 953.20.
- Optional: %B and bandwidth. Day 20 closed at 960.90: %B = (960.90 − 953.20) ÷ (1,083.59 − 953.20) = 0.0591. Bandwidth = (1,083.59 − 953.20) ÷ 1,018.39 × 100 = 12.80%.
- Move the 20-candle window on and repeat. On Day 60 the example's bands are 1,018.42 / 953.00 / 887.58.
Worked example — and calculate Bollinger Bands from your own prices
The table works through 60 daily candles of an imaginary stock, column by column — the same columns as the Excel sheet. To calculate Bollinger Bands for your own stock, clear the box and paste your closing prices from Excel or your broker's download.
Latest values
| Day | Close | Middle (SMA 20) | Std dev | Upper band | Lower band | %B | Bandwidth % |
|---|---|---|---|---|---|---|---|
| Day 1 | 1,001.15 | ||||||
| Day 2 | 987.95 | ||||||
| Day 3 | 1,009.15 | ||||||
| Day 4 | 1,012.60 | ||||||
| Day 5 | 993.25 | ||||||
| Day 6 | 1,008.60 | ||||||
| Day 7 | 1,013.60 | ||||||
| Day 8 | 1,001.55 | ||||||
| Day 9 | 1,031.55 | ||||||
| Day 10 | 1,040.05 | ||||||
| Day 11 | 1,033.15 | ||||||
| Day 12 | 1,064.80 | ||||||
| Day 13 | 1,083.55 | ||||||
| Day 14 | 1,067.95 | ||||||
| Day 15 | 1,063.50 | ||||||
| Day 16 | 1,030.20 | ||||||
| Day 17 | 1,012.20 | ||||||
| Day 18 | 981.60 | ||||||
| Day 19 | 970.55 | ||||||
| Day 20 | 960.90 | 1,018.3925 | 32.5985 | 1,083.5894 | 953.1956 | 0.0591 | 12.8039 |
| Day 21 | 978.30 | 1,017.2500 | 33.5687 | 1,084.3874 | 950.1126 | 0.2099 | 13.1998 |
| Day 22 | 958.85 | 1,015.7950 | 35.3885 | 1,086.5720 | 945.0180 | 0.0977 | 13.9353 |
| Day 23 | 946.75 | 1,012.6750 | 38.4547 | 1,089.5844 | 935.7656 | 0.0714 | 15.1894 |
| Day 24 | 937.95 | 1,008.9425 | 41.7615 | 1,092.4655 | 925.4195 | 0.0750 | 16.5565 |
| Day 25 | 927.85 | 1,005.6725 | 45.2749 | 1,096.2223 | 915.1227 | 0.0703 | 18.0078 |
| Day 26 | 911.20 | 1,000.8025 | 49.7185 | 1,100.2394 | 901.3656 | 0.0495 | 19.8714 |
| Day 27 | 905.15 | 995.3800 | 53.7755 | 1,102.9310 | 887.8290 | 0.0805 | 21.6100 |
| Day 28 | 885.95 | 989.6000 | 58.7813 | 1,107.1625 | 872.0375 | 0.0592 | 23.7596 |
| Day 29 | 874.70 | 981.7575 | 62.9749 | 1,107.7074 | 855.8076 | 0.0750 | 25.6580 |
| Day 30 | 855.80 | 972.5450 | 67.1144 | 1,106.7737 | 838.3163 | 0.0651 | 27.6036 |
| Day 31 | 862.15 | 963.9950 | 69.6917 | 1,103.3785 | 824.6115 | 0.1347 | 28.9179 |
| Day 32 | 866.45 | 954.0775 | 68.7477 | 1,091.5730 | 816.5820 | 0.1813 | 28.8227 |
| Day 33 | 845.10 | 942.1550 | 65.8768 | 1,073.9086 | 810.4014 | 0.1317 | 27.9686 |
| Day 34 | 851.55 | 931.3350 | 61.9833 | 1,055.3015 | 807.3685 | 0.1782 | 26.6213 |
| Day 35 | 860.20 | 921.1700 | 55.8411 | 1,032.8522 | 809.4878 | 0.2270 | 24.2479 |
| Day 36 | 854.80 | 912.4000 | 51.6448 | 1,015.6896 | 809.1104 | 0.2212 | 22.6413 |
| Day 37 | 877.20 | 905.6500 | 46.7501 | 999.1502 | 812.1498 | 0.3479 | 20.6482 |
| Day 38 | 888.45 | 900.9925 | 43.4770 | 987.9466 | 814.0384 | 0.4279 | 19.3018 |
| Day 39 | 905.40 | 897.7350 | 40.4809 | 978.6967 | 816.7733 | 0.5473 | 18.0369 |
| Day 40 | 896.80 | 894.5300 | 37.8019 | 970.1338 | 818.9262 | 0.5150 | 16.9036 |
| Day 41 | 889.60 | 890.0950 | 32.5524 | 955.1998 | 824.9902 | 0.4962 | 14.6287 |
| Day 42 | 895.30 | 886.9175 | 28.5404 | 943.9982 | 829.8368 | 0.5734 | 12.8717 |
| Day 43 | 919.00 | 885.5300 | 26.1743 | 937.8787 | 833.1813 | 0.8197 | 11.8231 |
| Day 44 | 918.35 | 884.5500 | 24.5071 | 933.5643 | 835.5357 | 0.8448 | 11.0823 |
| Day 45 | 906.25 | 883.4700 | 23.0051 | 929.4802 | 837.4598 | 0.7476 | 10.4158 |
| Day 46 | 932.10 | 884.5150 | 24.6564 | 933.8278 | 835.2022 | 0.9825 | 11.1502 |
| Day 47 | 944.35 | 886.4750 | 27.6010 | 941.6771 | 831.2729 | 1.0242 | 12.4543 |
| Day 48 | 948.70 | 889.6125 | 30.7499 | 951.1123 | 828.1127 | 0.9804 | 13.8262 |
| Day 49 | 966.35 | 894.1950 | 34.7544 | 963.7039 | 824.6861 | 1.0190 | 15.5467 |
| Day 50 | 955.60 | 899.1850 | 36.0249 | 971.2347 | 827.1353 | 0.8915 | 16.0256 |
| Day 51 | 969.10 | 904.5325 | 38.0134 | 980.5594 | 828.5056 | 0.9246 | 16.8102 |
| Day 52 | 984.35 | 910.4275 | 40.6976 | 991.8228 | 829.0322 | 0.9541 | 17.8807 |
| Day 53 | 980.90 | 917.2175 | 40.5602 | 998.3379 | 836.0971 | 0.8925 | 17.6884 |
| Day 54 | 962.50 | 922.7650 | 38.7462 | 1,000.2574 | 845.2726 | 0.7564 | 16.7957 |
| Day 55 | 960.20 | 927.7650 | 36.7507 | 1,001.2665 | 854.2635 | 0.7206 | 15.8449 |
| Day 56 | 967.35 | 933.3925 | 33.6319 | 1,000.6562 | 866.1288 | 0.7524 | 14.4127 |
| Day 57 | 971.00 | 938.0825 | 31.9678 | 1,002.0182 | 874.1468 | 0.7574 | 13.6311 |
| Day 58 | 981.75 | 942.7475 | 31.1826 | 1,005.1127 | 880.3823 | 0.8127 | 13.2305 |
| Day 59 | 994.85 | 947.2200 | 31.9115 | 1,011.0430 | 883.3970 | 0.8731 | 13.4758 |
| Day 60 | 1,012.35 | 952.9975 | 32.7101 | 1,018.4177 | 887.5773 | 0.9536 | 13.7294 |
The example prices are made up for this page — they are not real market data. Bollinger Bands is a calculation from past prices, not a forecast, a signal or advice to buy or sell. MyAlgoMate provides trading technology, not investment advice.
How to calculate Bollinger Bands in Excel
Put the headings in row 1 and the first candle in row 2, oldest at the top. Then type these formulas — each column uses the ones to its left:
- A
Day
A2 downwards: your dates, oldest at the top.
- B
Close
B2 downwards: the closing prices, oldest at the top.
- C
Middle (SMA 20)
C21
=AVERAGE(B2:B21)— then copy it down to the last row. - D
Std dev
D21
=STDEVP(B2:B21)— then copy it down to the last row. - E
Upper band
E21
=C21+2*D21— then copy it down to the last row. - F
Lower band
F21
=C21-2*D21— then copy it down to the last row. - G
%B
G21
=(B21-F21)/(E21-F21)— then copy it down to the last row. - H
Bandwidth %
H21
=(E21-F21)/C21*100— then copy it down to the last row.
The first 19 rows stay empty: every value needs 20 closes.
Prefer not to type them? The free sheet has every formula filled in for the example prices — replace the prices with yours and extend the rows. It opens in Microsoft Excel (we checked every value against the table above), and you can import it into Google Sheets or LibreOffice.
Download the free Bollinger Bands Excel sheet (.xlsx)What are Bollinger Bands?
Bollinger Bands are three lines on a price chart: a moving average in the middle and a band a set number of standard deviations above and below it. John Bollinger created them in the early 1980s, and his official site (bollingerbands.com) describes the idea as asking whether prices are high or low on a relative basis. People also search for them as “band Bollinger” — it is the same indicator.
The bands are a calculation from past prices. They are not a forecast, and this page does not suggest any trade.
Common settings
| Use | Average period | Standard deviations |
|---|---|---|
| Shorter term | 10 | 1.5 |
| Default, medium term | 20 | 2 |
| Longer term | 50 | 2.5 |
The table follows Fidelity's guide to typical values. John Bollinger's own note is to scale the multiplier with the length of the average: about 2.1 at 50 periods and 1.9 at 10 periods.
What John Bollinger says about the bands
His Bollinger Band rules include these points about reading the maths:
- Touches of the bands are “tags, not signals”.
- A close outside the bands is initially a sign of continuation, not a reversal.
- The default settings are starting points; the right values vary by market and task.
- About 90% of prices fall inside the default bands, not the 95% of a normal curve.
- Bandwidth's most popular use is spotting “the squeeze”.
Simple or exponential bands
Classic Bollinger Bands use a simple moving average, so the average and the standard deviation cover the same closes. If you use an exponential average instead, change it for both the middle band and the standard deviation.
At the defaults, bandwidth = (upper − lower) ÷ middle = 4 × standard deviation ÷ middle. The table below checks this on the worked example.
| Day | Std dev | Middle band | (Upper − lower) ÷ middle | 4 × std dev ÷ middle |
|---|---|---|---|---|
| Day 20 | 32.5985 | 1,018.3925 | 0.1280 | 0.1280 |
| Day 30 | 67.1144 | 972.5450 | 0.2760 | 0.2760 |
| Day 40 | 37.8019 | 894.5300 | 0.1690 | 0.1690 |
| Day 50 | 36.0249 | 899.1850 | 0.1603 | 0.1603 |
| Day 60 | 32.7101 | 952.9975 | 0.1373 | 0.1373 |
How many example closes fall inside the bands?
On the worked example's made-up prices, Day 20 to Day 60 (41 closes that have bands), a count from the table above:
| Where the close is | Number of closes |
|---|---|
| Inside the bands | 39 |
| Above the upper band | 2 |
| Below the lower band | 0 |
These prices are invented to show the calculation, so the counts say nothing about real markets. Paste your own closes into the calculator above to count yours.
What the bands show
The bands widen when the last 20 closes are spread out and narrow when they are bunched together, so the distance between them is a measure of recent volatility. A very narrow bandwidth is often called a “squeeze” — a description of quiet recent prices, not a forecast of what comes next.
A close outside the bands only means it is more than two standard deviations from the 20-period average. What you do with any of this is your own decision; the bands are a calculation from past prices.
Why your bands may not match your chart
- Sample instead of population standard deviation (STDEV / STDEV.S) — slightly wider bands.
- Different settings — period, multiplier, or an EMA instead of an SMA for the middle band.
- Different prices — spot vs futures, or another timeframe.
The middle band is an ordinary simple moving average — see the moving average formula.
Bollinger Bands calculation — questions, answered.
Yes. "Band Bollinger" is a common way of searching for Bollinger Bands, the indicator John Bollinger created in the early 1980s: a moving average with a band a set number of standard deviations above and below it.
John Bollinger's website says about 90% of prices fall inside the default bands, not the 95% a normal bell curve would give, because prices are not normally distributed. Studies cited on Wikipedia found about 88%. This describes how the maths behaves, nothing more.
They are the standard defaults: a 20-period average and 2 standard deviations. John Bollinger calls the defaults a starting point, and suggests a slightly larger multiplier for a longer average (2.1 at 50 periods) and a smaller one for a shorter average (1.9 at 10 periods).
The middle band is the 20-period simple moving average of the close. Work out the standard deviation of the same 20 closes; the upper band is the middle band + 2 × that standard deviation and the lower band is the middle band − 2 × it.
Closes in column B from row 2. In row 21 (the 20th close): middle =AVERAGE(B2:B21), standard deviation =STDEVP(B2:B21) (or STDEV.P), upper =C21+2*D21, lower =C21-2*D21. Copy the row down. The free sheet on this page also has %B and bandwidth.
The population standard deviation — dividing by 20, not 19 — which is STDEVP or STDEV.P in Excel. That is how John Bollinger defined it and how most charts calculate it. STDEV / STDEV.S divide by 19 and give slightly wider bands, a common reason a spreadsheet doesn't match a chart.
%B = (Close − Lower band) ÷ (Upper band − Lower band). It says where the close sits between the bands: 0 at the lower band, 1 at the upper band, 0.5 at the middle. It goes above 1 or below 0 when the close is outside the bands.
Bandwidth = (Upper band − Lower band) ÷ Middle band, often × 100 to show it as a percentage. Because the bands are 2 standard deviations either side, it equals 4 × standard deviation ÷ middle band — a measure of how spread out the last 20 closes are.
Bollinger Bands are set by the standard deviation of the closes around a simple moving average. Keltner Channels are usually set by a multiple of the Average True Range around an exponential moving average. See the ATR formula page for how ATR is calculated.
More indicator formulas, with Excel sheets
Turn your own rules into automated orders.
Already use Bollinger Bands in your own rules? MyAlgoMate's algo trading software places the orders your rules call for at 150+ Indian brokers — and TradeBridge turns your own TradingView or Chartink alerts into live orders. You decide the rules; we provide the technology.