- 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.
4.2 KiB
SQUEEZE: Squeeze Momentum
Squeeze Momentum combines Bollinger Band and Keltner Channel width analysis to detect low-volatility compression ("squeeze") states, while simultaneously measuring directional momentum via linear regression of a detrended price series. The dual output consists of a momentum histogram and a binary squeeze state indicator. When Bollinger Bands contract inside the Keltner Channel, the market is in a squeeze (coiling volatility); when the squeeze releases, the momentum histogram direction signals the likely breakout direction. The implementation combines five distinct computational stages, each using O(1) streaming techniques.
Historical Context
John Carter popularized the Squeeze indicator in his 2005 book Mastering the Trade, though the core concept of BB-inside-KC squeeze detection predates his work. The underlying principle is that volatility is mean-reverting: periods of unusually low volatility (measured by BB width falling below KC width) tend to precede large directional moves. Carter combined this squeeze detection with a momentum component derived from linear regression to provide directional bias. The specific construction uses the midpoint of a Donchian Channel averaged with SMA as a center line, computes the deviation of price from this averaged midpoint, and applies linear regression to this deviation series. The regression endpoint value serves as the momentum measure. This construction effectively measures detrended momentum, isolating the directional force from the trend component. The color-coded histogram (traditionally four colors based on momentum direction and acceleration) provides visual distinction between momentum increasing and decreasing in both directions.
Architecture & Physics
Five Computational Stages
-
SMA + Standard Deviation (Bollinger Bands): Circular buffer with running sum and sum-of-squares for O(1) variance computation. BB upper/lower = SMA
\pmbbMult\timesStdDev. -
EMA + ATR via RMA (Keltner Channel): EMA uses warmup-compensated exponential smoothing. ATR uses Wilder's RMA (also warmup-compensated) of True Range. KC upper/lower = EMA
\pmkcMult\timesATR. -
Squeeze detection: Binary comparison: if BB upper < KC upper AND BB lower > KC lower, squeeze is on. This means BB has contracted inside KC.
-
Donchian midline + delta: Circular buffers for highest-high and lowest-low over the period, with full O(n) scan per bar for max/min (no O(1) trick for running max). Delta = close
-(donchianMid + SMA) / 2. -
Linear regression of delta: Incremental running sums (
\Sigma y,\Sigma xy) for O(1) regression per bar. The momentum output is the regression line evaluated at the most recent point:\text{slope} \times (n-1) + \text{intercept}.
Warmup Compensation
EMA and RMA stages use the e = \beta^n warmup tracking with correction factor c = 1/(1-e) to eliminate initial bias.
Mathematical Foundation
Bollinger Bands (SMA + StdDev via running sums):
\mu = \frac{\Sigma x}{n}, \quad \sigma = \sqrt{\frac{\Sigma x^2}{n} - \mu^2}
BB_{upper} = \mu + m_{bb} \cdot \sigma, \quad BB_{lower} = \mu - m_{bb} \cdot \sigma
Keltner Channel (EMA + ATR):
EMA_t = \frac{\hat{E}_t}{1 - \beta^t}, \quad ATR_t = \frac{\hat{R}_t}{1 - \beta_r^t}
KC_{upper} = EMA + m_{kc} \cdot ATR, \quad KC_{lower} = EMA - m_{kc} \cdot ATR
Squeeze state:
Squeeze = \begin{cases} 1 & \text{if } BB_{upper} < KC_{upper} \text{ and } BB_{lower} > KC_{lower} \\ 0 & \text{otherwise} \end{cases}
Detrended price (delta):
\delta_t = x_t - \frac{(\text{DonchianMid}_t + \text{SMA}_t)}{2}
where \text{DonchianMid} = \frac{\max(H_{t-n+1..t}) + \min(L_{t-n+1..t})}{2}
Momentum (linear regression endpoint of delta):
m = \frac{n \cdot \Sigma_{xy} - \Sigma_x \cdot \Sigma_y}{n \cdot \Sigma_{x^2} - \Sigma_x^2}, \quad b = \frac{\Sigma_y - m \cdot \Sigma_x}{n}
Momentum_t = m \cdot (t_{\text{last}}) + b
Default parameters: period = 20, bbMult = 2.0, kcMult = 1.5.
Resources
- Carter, J. (2005). Mastering the Trade. McGraw-Hill, Chapter 11
- Bollinger, J. (2001). Bollinger on Bollinger Bands. McGraw-Hill
- PineScript reference:
squeeze.pine