Summary
SqueezeMomentum is RTTA's streaming TTM-style squeeze indicator: a binary flag
for Bollinger bands inside Keltner channels (volatility compression) plus a
linear-regression momentum of price relative to a hybrid mid-line.
Update API
result = rtta.SqueezeMomentum(window=20, bb_mult=2.0, kc_mult=1.5, fillna=True).update(close, high, low)
| Parameter | Default | Meaning |
|---|---|---|
window |
20 |
Lookback for BB, ATR/KC, Donchian, and linreg |
bb_mult |
2.0 |
Bollinger standard-deviation multiplier |
kc_mult |
1.5 |
Keltner ATR multiplier |
fillna |
True |
If False, NaN until window samples |
update(...) returns:
on—1.0if squeeze is on (BB inside KC), else0.0momentum— linear-regression value of the de-meaned series
advance(...) updates state; last() returns the cached result.
Theory Of Operation
Squeeze on means Bollinger bands (mean ± \(k\cdot\sigma\)) lie entirely
inside Keltner channels (mean ± \(m\cdot ATR\)). That is a classic TTM Squeeze
compression regime: realized volatility (BB) is low relative to average true
range width (KC). When the squeeze "fires" (on flips from 1 to 0), energy is
often released as a directional move.
Momentum measures where close sits versus a basis that averages the Donchian midpoint and the SMA of close, then fits a rolling linear regression (as in LazyBear / TTM-style histograms). Positive momentum favors upside release; negative favors downside.
Recurrence
Let \(n\) be the window, \(k=\texttt{bb\_mult}\), \(m=\texttt{kc\_mult}\).
Rolling mean and population stdev of close:
With ATR of length \(n\):
Squeeze flag:
Donchian mid and hybrid basis:
(value of the regression fit at the current bar, via LinearRegressionCore).
When fillna=False and fewer than \(n\) samples have been seen, both fields are
NaN.
Implementation Notes
- Implemented in
src/rtta/indicator.cppinclass SqueezeMomentum. - Uses rolling sum/sum2 for mean/variance,
RollingExtremefor HH/LL,ATR, andLinearRegressionCore linreg_. - Result type:
SqueezeMomentumResult(on,momentum). - Batch helper:
batch_squeeze_momentum. - Note: Keltner mid uses the SMA of close (
mean), not a separate EMA of typical price—matching this C++ implementation.
