Linear Regression Channel
OLS-fit a trend line over a rolling window; trade when price breaks outside its confidence band.
Understand what this strategy is actually betting on before you touch the parameter panel.
Read the model brief like a skeptic
Strategy families & selection
Validation & skepticism
The Intuition
The Linear Regression Channel strategy fits an Ordinary Least Squares (OLS) trend line to a rolling window of prices, then builds confidence-band channels around that trend line using the standard deviation of residuals. The strategy is long when price falls below the lower band (overshooting below the trend) and short when price rises above the upper band (overshooting above the trend).
Compared to Bollinger Bands, the LR Channel is more sophisticated: Bollinger Bands build the channel around a flat rolling mean, while the LR Channel builds it around a fitted trend line. This means in a trending market, the LR Channel correctly identifies the trend direction and only signals mean reversion when prices deviate from the trend — not from a flat level. In uptrending markets, this reduces the number of false short signals that plague simple Bollinger Bands.
The residual standard deviation serves as the volatility-adaptive bandwidth, similar to Bollinger Bands. When the price has been oscillating widely around the trend (large residuals), the bands are wide — fewer signals, but each represents a more extreme deviation. When the price has been tracking the trend closely (small residuals), the bands are narrow — more signals, but each represents a moderate deviation.
Key assumptions: (1) Price within the lookback window follows a linear trend — the OLS regression is a meaningful characterisation of the recent price path. If the trend is nonlinear (e.g., exponential growth), the residuals will be biased and the channel will be poorly calibrated. (2) Deviations from the fitted trend are mean-reverting rather than accumulating. (3) The slope and intercept estimated in the lookback window are predictive of the short-term future direction of the trend.
The strategy can fail when the linear trend breaks abruptly — a structural break in price (earnings surprise, major macro event) causes the price to move to a new level that is outside the channel permanently. The strategy will repeatedly signal "reversion" while the price continues to move in the new direction. Filtering signals by trend direction — only taking long signals in uptrending markets (positive OLS slope) and short signals in downtrending markets — can significantly reduce this failure mode.
The Math
Read this as a compact model summary: what the signal sees, what it ignores, and where fragility can creep in.
OLS fit over Close[t-n : t]:
predicted(t) = slope × (n-1) + intercept
residuals = Close[i] - (slope × i + intercept)
std_resid = std(residuals)
Upper(t) = predicted(t) + k × std_resid
Lower(t) = predicted(t) - k × std_resid
Signal(t) = +1 if Close(t) < Lower(t)
= -1 if Close(t) > Upper(t)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| window | int | 30 | Rolling OLS regression window (days) |
| num_std | float | 2.0 | Number of residual std devs for band width |
Source Code
Live source — fetched from engine/strategies/lr_channel.py
Further Reading
- Raschke, L. & Connors, L. (1995). Street Smarts. M. Gordon Publishing.
- Elder, A. (2002). Come Into My Trading Room. Wiley.
- Kaufman, P. (2013). Trading Systems and Methods, 5th ed. Wiley.
Related Statistical Strategies
Use nearby strategies to compare the same market hypothesis under different signal constructions.