- Linear Regression Channel plots a best-fit line through price data over a specified period with parallel bands at a configurable standard deviation...
- Parameterized by `period` (default 20), `multiplier` (default 2.0).
- Output range: Tracks input.
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
Linear Regression Channel plots a best-fit line through price data over a specified period with parallel bands at a configurable standard deviation of residuals. Unlike moving average envelopes that offset from a smoothed price, regression channels adapt their slope to the underlying trend and their width to actual dispersion around that trend. The algorithm uses ordinary least squares with precomputed index sums, requiring two passes per bar: one for the regression coefficients and one for the residual standard deviation.
Linear regression channels emerged from basic statistical methods applied to financial markets in the 1980s and 1990s. Gilbert Raff popularized "Raff Regression Channels" which use the same concept: fit a line, measure how far price wanders from it, and draw parallel bands at that distance.
The key insight separating regression channels from moving average envelopes: a moving average treats all recent prices equally, while linear regression fits a line that best explains the directional trend. The residuals (actual minus predicted) measure how much price deviates from this trajectory. When prices consistently touch the upper band, the trend is accelerating; when they compress toward the regression line, momentum is fading.
REGCHANNEL and SDCHANNEL implement identical algorithms. The distinction is purely naming convention: some platforms and literature label the indicator "Regression Channel" while others use "Standard Deviation Channel." Both compute OLS regression with population standard deviation of residuals.
Per bar: $O(n)$ due to two loops over the window (one for sums, one for residuals). Memory: a ring buffer of $n$ doubles. The index sums $\sum x$ and $\sum x^2$ are constants for fixed $n$ and can be precomputed at construction.