Files
QuanTAlib/lib/channels/abber/abber.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

4.4 KiB

ABBER: Aberration Bands

ABBER measures price deviation from a central moving average using mean absolute deviation rather than standard deviation, producing dynamic bands that adapt to volatility while remaining robust against extreme outliers. Where Bollinger Bands amplify outliers through squaring (the L^2 norm), ABBER uses raw absolute differences (the L^1 norm), so bands respond to typical price behavior rather than the occasional spike that yanks everything sideways. For a 20-period window with a 2.0 multiplier, ABBER contains approximately 89% of normally-distributed price action, but its real advantage emerges with fat-tailed distributions where standard deviation overreacts to single-bar anomalies.

Historical Context

The absolute deviation approach predates Bollinger's work by decades. Mean absolute deviation appears in early 20th-century statistics as a robust alternative to standard deviation, championed by statisticians who recognized that squaring deviations gives disproportionate weight to outliers. In financial markets, applying absolute deviation to band construction arrived after practitioners grew tired of watching Bollinger Bands blow out on single-bar anomalies such as flash crashes, earnings gaps, and fat-finger trades.

No single inventor claims credit for ABBER. The technique spread through trading floors where robustness mattered more than textbook elegance. The mathematical distinction is fundamental: standard deviation is a quadratic spring that amplifies outliers, while mean absolute deviation is a linear damper that treats all deviations proportionally. Under Gaussian assumptions, \text{MAD} \approx 0.7979 \sigma, so ABBER with multiplier 2.0 is roughly equivalent to Bollinger Bands with multiplier 1.6. But on real market data with kurtosis > 3, the gap widens in ABBER's favor.

Architecture & Physics

1. Central Tendency (SMA)

The middle band is a Simple Moving Average over the lookback window:

\text{Middle}_t = \frac{1}{n} \sum_{i=0}^{n-1} x_{t-i}

2. Absolute Deviation

Each bar's deviation is measured against the previous middle band value:

d_t = |x_t - \text{Middle}_{t-1}|

3. Average Absolute Deviation

The deviation series is itself averaged over the same window:

\text{AvgDev}_t = \frac{1}{n} \sum_{i=0}^{n-1} d_{t-i}

4. Band Construction

\text{Upper}_t = \text{Middle}_t + k \cdot \text{AvgDev}_t \text{Lower}_t = \text{Middle}_t - k \cdot \text{AvgDev}_t

5. Complexity

Both the SMA and the average deviation use circular buffers with running sums, yielding O(1) per bar in streaming mode. The SIMD-accelerable portion is the final band construction step (\text{Middle} \pm k \cdot \text{AvgDev}), while the running-sum maintenance is inherently serial.

Mathematical Foundation

Parameters

Parameter Description Default Constraint
period Lookback window for SMA and deviation averaging 20 > 0
multiplier Band width scale factor (k) 2.0 > 0
source Input price series close
ma_line Pre-computed moving average (center line) SMA configurable

Relationship to Standard Deviation

For a normal distribution:

\text{MAD} = \sigma \sqrt{\frac{2}{\pi}} \approx 0.7979\,\sigma

Therefore ABBER with k = 2.0 captures approximately the same range as Bollinger Bands with k \approx 1.596.

Pseudo-code

function ABBER(source, ma_line, period, multiplier):
    // Deviation from center line
    deviation = |source - ma_line|

    // Average absolute deviation (SMA of deviations)
    avg_dev = SMA(deviation, period)

    // Band construction
    upper = ma_line + multiplier * avg_dev
    lower = ma_line - multiplier * avg_dev

    return [upper, lower, avg_dev]

Output Interpretation

Output Description
upper Upper aberration band
lower Lower aberration band
avg_dev Current average absolute deviation (band half-width before scaling)

Resources

  • Pham-Gia, T. & Hung, T.L. "The Mean and Median Absolute Deviations." Mathematical and Computer Modelling, 34(7-8), 2001. (MAD vs. standard deviation theory)
  • Bollinger, J. Bollinger on Bollinger Bands. McGraw-Hill, 2001. (Standard deviation band predecessor)
  • Hampel, F.R. "The Influence Curve and its Role in Robust Estimation." Journal of the American Statistical Association, 69(346), 1974. (Robustness theory for L^1 vs L^2 norms)