Repository navigation
Bollinger Bands
Bollinger Bands are a volatility-based envelope plotted around a simple moving average (SMA). The middle band is the SMA; the upper and lower bands are placed
In Navier-Stocks, Bollinger Bands provide the structural price boundaries used by the breakout detector to identify statistically significant price extensions. When price breaks decisively outside the bands with high volume, it signals a potential continuation or reversal.
Given a price series
The middle band at index
The population standard deviation of the same window:
The upper and lower bands:
Where the standard multiplier is
The relative width of the bands, expressed as a percentage of the middle band:
Narrow bands indicate low volatility (squeeze); wide bands indicate high volatility (expansion).
The position of a price relative to the bands, normalized to [0, 1]:
| %b Value | Meaning |
|---|---|
| Price above upper band (overextended bullish) | |
| Price at upper band | |
| Price at middle band (SMA) | |
| Price at lower band | |
| Price below lower band (overextended bearish) |
Candles from TickStore
│
▼
BollingerBands(prices, period=20, k=2)
│
├──► Bands{Upper, Middle, Lower}
│
▼
Breakout Detector (1.6)
── Checks if close is outside bands
── Confirms with volume breakout
── Publishes signal.intent.*
The breakout detector uses Bollinger Bands in two ways:
-
Breakout confirmation: A close outside the bands (
$%b < 0$ or$%b > 1$ ) with concurrent volume surge indicates a statistically significant move. -
Mean reversion context: When
$%b$ is extreme but volume is normal, price may revert to the middle band.
File: src/analysts/quantitative/indicators/bollinger.go
| Function | Input | Returns |
|---|---|---|
BollingerBands |
prices, period, multiplier |
(Bands, ok) |
BollingerBandsSeries |
prices, period, multiplier |
[]Bands |
BandWidth |
b Bands |
float64 |
PercentB |
price, b Bands |
float64 |
Underlying math primitives: src/pkg/math/math.go — Mean() and StdDev()
const DefaultBollingerPeriod = 20
const DefaultBollingerMultiplier = 2.0| Condition | Behaviour |
|---|---|
len(prices) < period |
ok = false |
period < 2 |
ok = false (variance undefined for n < 2) |
| Constant prices ( |
All three bands collapse to the same value |
BandWidth with Middle = 0
|
Returns 0 (avoids division by zero) |
PercentB with collapsed bands |
Returns 0 |
Given [10, 12, 11]:
- VWAP Indicator — primary trend anchor
- Volume Breakout Indicator — volume confirmation layer
-
src/analysts/quantitative/indicators/bollinger_test.go— comprehensive test suite -
wiki/Risk-Guardrails.md— operational integration details
- Home
- Core Architecture
- Indicator Reference
-
Developer Sandbox
- Local Environment & Quickstart (Pending)
- Testing & Backtesting Strategy (Pending)
-
Operational Systems
- Infrastructure Runbook & Recovery (Pending)