Indicator Formula

Technical Details — Bollinger Bands (BB)
Section titled “Technical Details — Bollinger Bands (BB)”Overview
Section titled “Overview”Bollinger Bands use SMA ± standard deviation multiples.
Mathematical Derivation
Step 1 — Calculate Middle Band (SMA)
Section titled “Step 1 — Calculate Middle Band (SMA)”Purpose: Establish the center line.
$$Middle = SMA(Close, n)$$
Where:
- $$n$$ = Period (default 20)
What This Measures: Average price over the period
Step 2 — Calculate Standard Deviation
Section titled “Step 2 — Calculate Standard Deviation”Purpose: Measure price dispersion.
$$\sigma = \sqrt{\frac{\sum(Close_i - SMA)^2}{n}}$$
What This Measures: Price volatility
Step 3 — Calculate Bands
Section titled “Step 3 — Calculate Bands”Purpose: Set bands at standard deviation multiples.
$$Upper = Middle + k \times \sigma$$ $$Lower = Middle - k \times \sigma$$
Where:
- $$k$$ = Multiplier (default 2.0)
What This Measures: Statistical price boundaries
Step 4 — Calculate %B
Section titled “Step 4 — Calculate %B”Purpose: Normalize price position within bands.
$$%B = \frac{Close - Lower}{Upper - Lower}$$
What This Measures: Where price sits within the bands (0=lower, 0.5=middle, 1=upper)
Compact Formula Summary
$$Middle = SMA(Close, n)$$ $$Upper = Middle + k\sigma$$ $$Lower = Middle - k\sigma$$ $$%B = (Close - Lower)/(Upper - Lower)$$
Defaults: Period = 20, Multiplier = 2.0
Complete Calculation Example
With SMA = 45, σ = 1.5, k = 2: Upper = 45 + 2×1.5 = 48 Lower = 45 - 2×1.5 = 42 If Close = 47: %B = (47-42)/(48-42) = 0.83 (near upper band)
Key Takeaways from the Example
- Band Width: Wider bands = more volatile, narrower = less volatile
- %B: 0 = at lower band, 1 = at upper band, >1 = above upper band
- Squeeze: Very narrow bands often precede large moves