Skip to content

The Bollinger Bandwidth Delta (

Source: Notion | Last edited: 2025-03-19 | ID: 1bb2d2dc-3ef...


The Bollinger Bandwidth Delta (BBD) oscillator represents a sophisticated analytical tool within the realm of technical analysis, specifically engineered to quantify the rate of change in market volatility. This indicator calculates the dynamic expansion and contraction of Bollinger Bands—a volatility measurement construct—and transforms this information into an oscillator format that traders can utilize to identify potential trend reversals and volatility breakouts.

Prior to the implementation of horizontal reference levels at +10 and -10, practitioners faced challenges in objectively determining when the oscillator had reached significant extremes. The addition of these demarcation lines creates a structured frame-work for interpreting the indicator’s output—establishing clear boundaries for what constitutes meaningful volatility expansion or contraction within a specific time-frame.

The algorithmic foundation of this indicator merits careful examination. At its core, the BBD first calculates standard Bollinger Bands using the input parameters InpPeriodBB (default 20) and InpDeviation (default 2.0), which determine the look-back period and standard deviation multiplier respectively. The indicator then computes the Bollinger Bandwidth—defined as 2*deviation*StdDev/MA—which represents the width of the bands normalized by the moving average. Finally, the indicator calculates the delta or rate of change in this bandwidth over the period specified by InpPeriodDelta (default 20).

The code execution follows a sequential process that begins with initialization in the OnInit() function. Here, the indicator configures its visual properties, allocates buffer arrays, and creates necessary handles for accessing the moving average and standard deviation calculations. The computational heart of the indicator resides in the OnCalculate() function, which processes incoming price data in a step-wise fashion. For each calculation point, the code determines the current bandwidth, compares it to the bandwidth from delta periods ago, and then calculates the percentage change—or the absolute change normalized by the point value—depending on the InpPercent parameter setting.

The color-coding mechanism implemented through BufferColors provides an intuitive visual representation of the oscillator’s movement—green histograms indicate increasing bandwidth (expanding volatility), red histograms signify decreasing bandwidth (contracting volatility), and dark gray denotes stability. This trichromatic system enables traders to rapidly assess directional changes in market volatility without requiring elaborate interpretative analysis.

The newly implemented horizontal levels at +10 and -10 serve as critical decision thresholds. When the histogram oscillates between these boundaries—bouncing from one extreme to another—it indicates a range-bound volatility regime where prices may be consolidating before a significant move. Excursions beyond these levels potentially signal unusual volatility events that warrant heightened attention from market participants—particularly those employing mean-reversion strategies or volatility-based trading systems.

From a feature extraction perspective for financial time-series forecasting, the BBD indicator with horizontal boundaries offers several advantages. First, it transforms raw price action into a normalized metric of volatility change—a feature often associated with impending market movements. Second, the bounded oscillator format with defined thresholds creates easily quantifiable regime identification variables that can be incorporated into machine learning models as categorical features. Third, the direction and magnitude of the oscillator’s movement provide gradient information about the acceleration or deceleration of market volatility—a potential leading indicator for trend exhaustion or continuation.

The structural elegance of this indicator lies in its computational efficiency. By leveraging pre-calculated moving averages and standard deviations through the iMA and iStdDev functions respectively, the algorithm minimizes redundant calculations—an important consideration for high-frequency data processing environments. Furthermore, the implementation of ArraySetAsSeries ensures optimal memory management by organizing data in a time-descending order, facilitating efficient backward iterations through the price series.

Veteran users of technical analysis will recognize that this modified BBD indicator bridges the conceptual gap between traditional oscillator-based and volatility-based trading methodologies—providing a unified framework for market analysis that accounts for both price direction and volatility dynamics. The horizontal levels transform what was previously a relative measurement tool into a more absolute reference system—adding significant practical value for systematic trading implementations.

The indicator’s value proposition extends beyond mere visualization—it represents a quantitative mechanism for identifying potential volatility regime shifts—those crucial junctures where market behavior undergoes fundamental changes in character. By monitoring transitions across the designated threshold levels, traders gain advance insight into evolving market conditions that often precede substantial price movements.

For a given time series of prices P = {p₁, p₂, …, pₙ}, the Bollinger Bandwidth Delta calculation proceeds through several distinct computational stages.

First, we compute the Simple Moving Average (SMA) over a period of n (default 20):

SMAt=1ni=0n1ptiSMA_t = \frac{1}{n} \sum_{i=0}^{n-1} p_{t-i}

Next, we calculate the Standard Deviation (σ) over the same period:

σt=1ni=0n1(ptiSMAt)2\sigma_t = \sqrt{\frac{1}{n} \sum_{i=0}^{n-1} (p_{t-i} - \text{SMA}_t)^2}

The Bollinger Bandwidth at time t is then defined as:

BWt=2×d×σtSMAt\text{BW}_t = \frac{2 \times d \times \sigma_t}{\text{SMA}_t}

Where d represents the deviation multiplier (default 2.0).

Finally, the Bollinger Bandwidth Delta (BBD) is computed as either:

  1. Percentage change (when InpPercent = INPUT_YES):
BBDt=100×BWtBWtδBWtδ\text{BBD}_t = 100 \times \frac{\text{BW}_t - \text{BW}_{t-\delta}}{\text{BW}_{t-\delta}}
  1. Absolute change normalized by point value (when InpPercent = INPUT_NO):
BBDt=BWtBWtδPoint\text{BBD}_t = \frac{\text{BW}_t - \text{BW}_{t-\delta}}{\text{Point}}

Where δ represents the delta period (default 20) and Point is the minimum price increment for the financial instrument.

The indicator assigns colors to the histogram based on the following conditions:

Colort={Green,if BBDt>BBDt1Red,if BBDt<BBDt1DarkGray,if BBDt=BBDt1\text{Color}_t = \begin{cases} \text{Green}, & \text{if } \text{BBD}_t > \text{BBD}_{t-1} \\ \text{Red}, & \text{if } \text{BBD}_t < \text{BBD}_{t-1} \\ \text{DarkGray}, & \text{if } \text{BBD}_t = \text{BBD}_{t-1} \end{cases}

The horizontal levels at +10 and -10 establish the threshold boundaries for identifying range-bound volatility conditions versus potential volatility breakouts—a critical demarcation for statistical arbitrage and mean-reversion trading systems.


Comprehensive Mathematical Formulation of Bollinger Bandwidth Delta (BBD)

Section titled “Comprehensive Mathematical Formulation of Bollinger Bandwidth Delta (BBD)”

Let us denote a financial time series with n observations as:

P=p1,p2,...,pnP = {p₁, p₂, ..., pₙ}

Where pₜ represents the price at time t, determined by InpAppliedPrice (default: PRICE_CLOSE).

For a given period nᵦᵦ (parameter InpPeriodBB, default: 20), the Simple Moving Average at time t is defined as:

SMAt(nββ)=1/nββββ1ptiSMAₜ(nᵦᵦ) = 1/nᵦᵦ ∑ᵢ₌₀ⁿᵦᵦ⁻¹ pₜ₋ᵢ

The Standard Deviation over the same period is computed as:

σt(nββ)=(1/nββββ1(ptiSMAt(nββ))2)σₜ(nᵦᵦ) = √(1/nᵦᵦ ∑ᵢ₌₀ⁿᵦᵦ⁻¹ (pₜ₋ᵢ - SMAₜ(nᵦᵦ))²)

The Upper and Lower Bollinger Bands are defined as:

UpperBandt=SMAt(nββ)+d×σt(nββ)LowerBandt=SMAt(nββ)d×σt(nββ)Upper Bandₜ = SMAₜ(nᵦᵦ) + d × σₜ(nᵦᵦ) Lower Bandₜ = SMAₜ(nᵦᵦ) - d × σₜ(nᵦᵦ)

Where d represents the deviation multiplier (parameter InpDeviation, default: 2.0).

The Bollinger Bandwidth at time t is defined as the normalized width of the bands:

BWt=(UpperBandtLowerBandt)/SMAt(nββ)BWₜ = (Upper Bandₜ - Lower Bandₜ)/SMAₜ(nᵦᵦ)

Which simplifies to:

BWt=(2×d×σt(nββ))/SMAt(nββ)BWₜ = (2 × d × σₜ(nᵦᵦ))/SMAₜ(nᵦᵦ)

This is implemented in the code as:

BufferWidtht=(2×deviation×BufferDevt)/BufferMAtBufferWidthₜ = (2 × deviation × BufferDevₜ)/BufferMAₜ

Let δ represent the delta period (parameter InpPeriodDelta, default: 20), which determines the lookback period for calculating the rate of change in bandwidth.

Step 6: Bollinger Bandwidth Delta Calculation

Section titled “Step 6: Bollinger Bandwidth Delta Calculation”

The Bollinger Bandwidth Delta (BBD) at time t is calculated using one of two methods, depending on the InpPercent parameter:

6a: Percentage Change (when InpPercent = INPUT_YES)

Section titled “6a: Percentage Change (when InpPercent = INPUT_YES)”
BBDt=100×(BWtBWtδ)/BWtδBBDₜ = 100 × (BWₜ - BWₜ₋δ)/BWₜ₋δ

This is implemented in the code as:

BufferBBDt=100×(BufferWidthtBufferWidtht+δ1)/BufferWidtht+δ1BufferBBDₜ = 100 × (BufferWidthₜ - BufferWidthₜ₊δ₋₁)/BufferWidthₜ₊δ₋₁

Note: The indexing appears reversed in the code due to the arrays being set as time series with ArraySetAsSeries, where newer data points have lower indices.

6b: Absolute Change Normalized by Point (when InpPercent = INPUT_NO)

Section titled “6b: Absolute Change Normalized by Point (when InpPercent = INPUT_NO)”
BBDt=(BWtBWtδ)/PointBBDₜ = (BWₜ - BWₜ₋δ)/Point

This is implemented in the code as:

BufferBBDt=(BufferWidthtBufferWidtht+δ1)/PointBufferBBDₜ = (BufferWidthₜ - BufferWidthₜ₊δ₋₁)/Point

Where Point is the minimum price increment for the financial instrument.

The color of the histogram at time t is determined by comparing the current BBD value with the previous one:

BufferColorst=0(Green),ifBufferBBDt>BufferBBDt+11(Red),ifBufferBBDt<BufferBBDt+12(DarkGray),ifBufferBBDt=BufferBBDt+1BufferColorsₜ = { 0 (Green), if BufferBBDₜ > BufferBBDₜ₊₁ 1 (Red), if BufferBBDₜ < BufferBBDₜ₊₁ 2 (DarkGray), if BufferBBDₜ = BufferBBDₜ₊₁ }

The indicator establishes horizontal threshold levels at:

UpperThreshold=+10LowerThreshold=10Upper Threshold = +10 Lower Threshold = -10

These boundaries create a defined range for interpreting the oscillator:

  • When BBDₜ oscillates between -10 and +10: Range-bound volatility regime
  • When BBDₜ > +10: Significant volatility expansion
  • When BBDₜ < -10: Significant volatility contraction

The visual rendering of the indicator is defined by:

  • Plot Type: Color Histogram (DRAW_COLOR_HISTOGRAM)
  • Color Scheme: Green, Red, DarkGray (clrGreen, clrRed, clrDarkGray)
  • Line Style: Solid (STYLE_SOLID)
  • Line Width: 2 pixels
  • Horizontal Levels Style: Dashed lines (STYLE_DASH)
  • Horizontal Levels Color: Dark Gray (clrDarkGray)
  • Horizontal Levels Width: 1 pixel These mathematical formulations completely define the Bollinger Bandwidth Delta indicator’s computational methodology and visual representation.