How Bollinger Bands Are Calculated

Bollinger Bands calculation formula inputs moving average standard deviation.

Bollinger Bands in one simple definition

Bollinger Bands are a set of three lines built from the same moving window of price data:

  • a middle band: the moving average of the price
  • an upper band: the middle band plus a multiple of the rolling standard deviation
  • a lower band: the middle band minus a multiple of the rolling standard deviation

The main idea is that the distance between the upper and lower bands changes with volatility: when price variability increases, the rolling standard deviation rises and the bands widen; when variability falls, the bands narrow.

The calculation formula (with parameters)

To calculate Bollinger Bands at a given time, you need a time series of prices (for example, closing prices). Then:

Parameters

  • Period (N): the number of observations in the moving window used for the average and standard deviation.
  • Multiplier (k): how many standard deviations to add/subtract.
  • Price input: what price you apply the calculation to (commonly close, but the method requires that you consistently use one choice).

Step-by-step mechanics

Let Pₜ be the chosen price at time t.

  1. Middle band (moving average) [ \text{MB}t = \frac{1}{N} \sum{i=0}^{N-1} P_{t-i} ]

  2. Rolling standard deviation Compute the standard deviation of the last N prices around the same moving average (use a consistent definition of standard deviation across your calculations). [ \text{SD}t = \sqrt{\frac{1}{N} \sum{i=0}^{N-1} \left(P_{t-i} - \text{MB}_t\right)^2} ] (Some implementations use (N-1) instead of (N) for an unbiased estimator; the qualitative band behavior remains similar, but exact values can differ.)

  3. Upper and lower bands [ \text{UB}_t = \text{MB}_t + k \cdot \text{SD}_t ] [ \text{LB}_t = \text{MB}_t - k \cdot \text{SD}_t ]

These three bands are computed repeatedly as new price points arrive, each time using the most recent N observations.

What data you need (and what changes the output)

Bollinger Bands are completely determined by your inputs. For an accurate, independent explanation, state your assumptions explicitly:

  1. Price series choice You must specify which series you use as (P_t): for example, closing prices. Changing the series (close vs another field) changes the values because both the moving average and the standard deviation use that same input.

  2. Sampling frequency The period N counts observations, not absolute time. For example, if your data is daily, N=20 means 20 trading days; if your data is hourly, it means 20 hours. The “lookback length” therefore depends on your data frequency.

  3. N and k settings

  • A larger N generally smooths the middle band more and makes the standard deviation respond more slowly to changes.
  • A larger k increases the vertical distance between the upper and lower bands for the same (\text{SD}_t).
  1. Start-up / missing values For the first N−1 points, you cannot compute a full-window moving average and standard deviation. Different software may handle the early period differently (e.g., leaving values blank), so when verifying calculations, align with the same handling rules.

A concrete example you can verify

Assume you have chosen:

  • a lookback window N = 5
  • a multiplier k = 2
  • price input (P_t) as your series

At some time t, take the last five prices: [ P_{t-4},\ P_{t-3},\ P_{t-2},\ P_{t-1},\ P_t ]

  1. Compute the middle band: [ \text{MB}t = \frac{P{t-4}+P_{t-3}+P_{t-2}+P_{t-1}+P_t}{5} ]

  2. Compute the standard deviation around that middle band: [ \text{SD}t = \sqrt{\frac{1}{5}\sum{i=0}^{4}(P_{t-i}-\text{MB}_t)^2} ]

  3. Compute the bands: [ \text{UB}_t = \text{MB}_t + 2\cdot \text{SD}_t ] [ \text{LB}_t = \text{MB}_t - 2\cdot \text{SD}_t ]

If you repeat this for the next time step (t+1) using the next set of five prices, you get the next bands. This rolling recomputation is the core “how it works.”

Material limitations and failure modes

Bollinger Bands describe how far price is moving relative to a moving window’s variability, but they have important limitations:

  1. Assumptions about volatility stability are not guaranteed The standard deviation is computed from recent data only. If market behavior changes regime (for example, volatility shifts abruptly), the bands may lag behind how quickly conditions change.

  2. Different standard-deviation definitions can lead to different numbers As noted, some implementations use (N) vs (N-1) in the standard deviation. If you compare results across tools, mismatched formulas can make bands look “inconsistent” even when both are reasonable.

  3. Choice of price input matters If your price series differs (e.g., you use close vs another input), the middle band and standard deviation change, so band locations change too. You cannot verify correctness without matching the input series.

  4. Descriptive tool, not an automatic decision rule A band “touch” or “cross” is not, by itself, a reliable signal of future outcomes. Historical relationships can break because volatility is influenced by many factors, and correlations are not stable.

  5. Backtesting pitfalls If someone evaluates a strategy that relies on Bollinger Bands, results can be sensitive to data frequency, parameter choices (N and k), and the exact implementation details. Overfitting is a risk when parameters are tuned to past data.

How to verify a calculation independently

You can validate Bollinger Bands in a reproducible way without relying on any particular platform:

  • Confirm the exact inputs: N, k, the price series (P_t), and whether standard deviation uses (N) or (N-1).
  • For a small window (like N=5 or N=10), compute MB, SD, UB, and LB manually from the raw numbers.
  • Check consistency at multiple time points (not only the first computed value).

If your computed values match the same formulas used by a tool, you have verified the calculation. If they don’t, the mismatch usually comes from input choice, parameter differences, or standard-deviation convention.

Next question: what bands are measuring

Bollinger Bands are a volatility-based construction using a moving average and rolling standard deviation. A useful next step is to clarify how they relate to other volatility or moving-average concepts, and how changing N and k changes responsiveness. If you want, you can compare the idea of “distance from a rolling mean” to other volatility measures to understand what this specific method is and is not capturing.

Trading foreign exchange and CFDs involves substantial risk. Information on FoxiForex is educational and is not personal financial advice. Sponsored placements are labelled clearly.