Files
QuanTAlib/lib/channels/accbands/accbands.md
T
Miha Kralj 90d5638008 Add new moving average implementations: LTMA, MCNMA, NLMA, NMA, NYQMA, RAIN, and TRAMA
- LTMA (Linear Trend Moving Average): Introduces a predictive moving average using dual cascaded EMAs for trend estimation.
- MCNMA (McNicholl EMA): Implements a zero-lag TEMA using a cascaded EMA structure for enhanced responsiveness.
- NLMA (Non-Lag Moving Average): Utilizes a damped cosine kernel to achieve reduced lag in moving averages.
- NMA (Natural Moving Average): Adapts smoothing based on volatility profiles using a square-root kernel.
- NYQMA (Nyquist Moving Average): Applies the Nyquist-Shannon theorem to prevent aliasing in cascaded moving averages.
- RAIN (Rainbow Moving Average): Combines multiple SMA layers with weighted averages for multi-scale smoothing.
- TRAMA (Trend Regularity Adaptive Moving Average): Adapts smoothing based on the frequency of new highs and lows in price data.
2026-02-20 21:40:32 -08:00

3.7 KiB

ACCBANDS: Acceleration Bands

Acceleration Bands construct a volatility envelope using the intra-bar high-low range rather than close-to-close standard deviation, creating channels that accommodate the full price excursion of the underlying asset. Each bar's contribution to band width is normalized by price level (w = (H-L)/(H+L)), making the bands scale-invariant across instruments. Three independent Simple Moving Averages of the adjusted high, adjusted low, and close prices form the upper, lower, and middle bands respectively. Headley's original breakout rule declares a trend when price closes outside the bands for two consecutive bars.

Historical Context

Price Headley developed Acceleration Bands and detailed them in Big Trends in Trading (Wiley, 2002). Headley observed that standard deviation bands often lag in fast-moving breakout scenarios because they require several bars of expanded volatility before the bands visibly widen. By incorporating High and Low prices directly into the band width calculation through a per-bar normalized range, he created a system that reacts immediately to range expansion.

The normalization w = (H-L)/(H+L) is the key design choice. Dividing range by the sum of high and low produces a dimensionless ratio that is comparable across any price level. A $5 stock with a $0.50 range and a $500 stock with a $50 range both produce w = 0.05. The default factor of 4.0 was Headley's empirically determined value for equity markets on daily timeframes, matching the TA-Lib reference implementation.

Architecture & Physics

1. Per-Bar Normalized Width

For each bar, compute the range as a fraction of total price:

w_t = \frac{H_t - L_t}{H_t + L_t}

When H_t + L_t = 0 (price is zero), w_t = 0 to prevent division by zero.

2. Adjusted Prices

The high and low are expanded by the normalized width scaled by the factor:

\text{AdjHigh}_t = H_t \times (1 + F \cdot w_t) \text{AdjLow}_t = L_t \times (1 - F \cdot w_t)

3. Band Construction (Three SMAs)

\text{Upper}_t = \text{SMA}(\text{AdjHigh}, n) \text{Lower}_t = \text{SMA}(\text{AdjLow}, n) \text{Middle}_t = \text{SMA}(\text{Close}, n)

4. Complexity

Three independent circular buffers maintain running sums for O(1) streaming updates. Each bar requires computing w_t, the two adjusted prices, and three buffer updates.

Mathematical Foundation

Parameters

Parameter Description Default Constraint
period Lookback period for the three SMAs (n) 20 > 0
factor Multiplier for normalized width (F) 4.0 > 0

Pseudo-code

function ACCBANDS(high, low, close, period, factor):
    // Per-bar normalized width
    denom = high + low
    w = denom ≠ 0 ? (high - low) / denom : 0

    // Adjusted prices
    adj_high = high * (1 + factor * w)
    adj_low  = low  * (1 - factor * w)

    // Three independent SMAs
    upper  = SMA(adj_high, period)
    lower  = SMA(adj_low, period)
    middle = SMA(close, period)

    return [middle, upper, lower]

Breakout Rule (Headley)

A trend is confirmed when:

\text{Close}_t > \text{Upper}_t \quad \text{AND} \quad \text{Close}_{t-1} > \text{Upper}_{t-1}

(Two consecutive closes above the upper band.) Reverse logic for downside breakouts.

Output Interpretation

Output Description
upper SMA of adjusted highs (resistance envelope)
lower SMA of adjusted lows (support envelope)
middle SMA of close (center line)

Resources

  • Headley, P. Big Trends in Trading. Wiley, 2002. (Original Acceleration Bands specification)
  • TA-Lib TA_ACCBANDS function. (Reference implementation with factor = 4.0)