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

ParameterTypeDefaultDescription
window int 30 Rolling OLS regression window (days)
num_std float 2.0 Number of residual std devs for band width

Source Code

def run(ticker: str, start: str, end: str, **params) -> dict:
    window = int(params.get("window", 30))
    num_std = float(params.get("num_std", 2.0))
    df = fetch_ohlcv(ticker, start, end)

    close = df["Close"].values
    pos = np.zeros(len(close))

    for i in range(window, len(close)):
        y = close[i - window: i]
        x = np.arange(window)
        slope, intercept, _, _, _ = stats.linregress(x, y)
        predicted = slope * (window - 1) + intercept
        residuals = y - (slope * x + intercept)
        std_resid = np.std(residuals)
        upper = predicted + num_std * std_resid
        lower = predicted - num_std * std_resid
        current = close[i]
        if current < lower:
            pos[i] = 1.0
        elif current > upper:
            pos[i] = -1.0

    positions = pd.Series(pos, index=df.index)
    return run_backtest(df, positions, ticker=ticker, start=start, end=end,
                        strategy=METADATA["slug"], params={"window": window, "num_std": num_std})

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.

When It Works / When It Fails

Works
  • Clear linear trend with normally-distributed residuals
  • Channel-based mean reversion around a sloped OLS line
  • Trending instruments that oscillate around their trend
Fails
  • Non-linear price paths that break the OLS assumptions
  • Fat-tailed residuals invalidate the band thresholds
  • Instruments trending strongly away from channel slope

Regime Fit

Transition / Calm vol
Best conditions at 1.0. Channel residuals are well-behaved and reversion signals are reliable.
Transition / Normal vol
Strong fit at 0.75. Residuals slightly wider but channel structure holds.
Bull or Bear / Calm vol
Reduced to 0.7. A sloped channel adapts better than a flat SMA but drift can exceed band width.
Any regime / Stressed vol
Drops to 0.0. Residuals blow out; OLS channel assumptions break entirely.

Compared to Alternatives

vs Bollinger
Bollinger uses a flat SMA as center; LR Channel uses a sloped OLS regression line. LR Channel is better for instruments that trend while also oscillating around the trend.
vs OU Reversion
OU models stochastic mean-reversion speed via a fitted SDE; LR Channel is a geometric/deterministic regression band. Different frameworks applied to the same reversal idea.
vs Zscore
Zscore standardizes return series deviations; LR Channel measures price residuals around a trend slope. LR Channel captures the directional trend explicitly in its center.
Run This Strategy →