On This Page
- What is a linear regression channel?
- How is a linear regression channel calculated?
- Worked example
- Standard error, standard deviation and Raff channels
- Linear regression channel example: one close, two fits
- How traders use a linear regression channel
- Limitations of linear regression channels
- Bottom line
- FAQ
Key Takeaways
- The center line is an ordinary least-squares fit of price against bar index over a fixed lookback, chosen to minimize the sum of squared deviations between price and the line.
- Slope is fitted price change per bar. Express 100 × slope / reference price on the same bar interval when comparing percentage rates across symbols.
- The parallel bands are offset by a chosen deviation measure: the standard error of the residuals, the standard deviation of price, an average deviation, or the maximum deviation used in a Raff channel.
- A rolling full-window channel refits the selected observations each bar. A fixed-window drawing retains its fit when the same observations remain selected.
- Read slope, band distance and R-squared separately: fitted pace, price-unit dispersion and the share of sample variation explained by the line.
What is a linear regression channel?
A linear regression channel is a price channel built from a least-squares line fitted to a fixed window of prices, with two parallel bands set a chosen multiple of a deviation measure above and below it. The line’s slope shows the fitted pace of the trend, and the bands show how widely prices are dispersed.
This entry uses completed closes and bands at two residual standard errors. Read three outputs separately: slope describes fitted pace, band distance describes dispersion in price units, and R-squared describes the share of sample variation explained by the line.
How is a linear regression channel calculated?
Fit P = a + b × t across n observations. Choose b = Σ[(t − mean t)(P − mean P)] / Σ[(t − mean t)²], then a = mean P − b × mean t.
Residuals are observed prices minus fitted values. For n greater than 2, residual standard error is sqrt(Σresidual² / (n − 2)). Add and subtract twice that value to draw this example’s boundaries.
For nonconstant prices, R-squared = 1 − residual sum of squares / total centered sum of squares. The selected window and price input determine all three outputs.
Formula
b = Sum((t − mean t)(P − mean P)) / Sum((t − mean t)²); a = mean P − b × mean t; Center(t) = a + b × t; Bands(t) = Center(t) +/- k × D; D = √(Sum((P − Center(t))²) / (n − 2)) when D is the residual standard error- Use n greater than 2 and distinct bar indices. P is the selected price input; this example fits closes to equally spaced bar indices.
- b is the least-squares slope, the fitted price change per bar, and a is the intercept.
- Least squares picks a and b to minimize the sum of squared residuals, Sum((P − Center(t))²).
- The residual standard error divides that sum by n − 2, the degrees of freedom left after estimating both a slope and an intercept, not by n or n − 1.
- This example uses residual standard error. Other channel modes use price standard deviation, average absolute deviation or maximum deviation; specify the selected price input and denominator.
- k is the band multiplier, commonly 1 or 2 when D is a standard error and fixed at 1 when D is a maximum deviation.
Worked Example
The chart contains 22 daily closes. First fit a 20-bar channel to bars 2 through 21, ending at the $53.40 close. Then fit bars 3 through 22 after the new $54.30 close. Both channels use bands at two residual standard errors.
- Fit over the 20-bar window: slope +$0.177 per bar, so the line rises 19 × $0.177 = $3.36, from $49.05 at the oldest bar to $52.41 at the newest, with R-squared 0.90
- Residual standard error $0.36, so the bands at the newest bar sit at $52.41 + $0.72 = $53.13 and $52.41 − $0.72 = $51.69
- The $53.40 close is ($53.40 − $52.41) / $0.36 = 2.75 standard errors above the line, $0.27 outside the upper band
- After bar 22 closes at $54.30, fit bars 3 through 22: slope $0.21 per bar, residual standard error $0.50 and R-squared 0.86
- On the refit, the upper band above that same prior bar is $53.73, so the unchanged $53.40 close now plots $0.33 inside the channel at 1.34 standard errors
The unchanged $53.40 close is $0.27 above the first fit’s upper band and $0.33 below the second fit’s upper band. The selected observations changed, so the fitted line and band distance changed. Retain the fit calculated at each decision bar when recording a trading signal.
Standard error, standard deviation and Raff channels
Channel modes use different width statistics. A maximum close-to-line distance encloses the selected closes. A maximum high-low distance encloses the selected candle ranges. These are different Raff constructions.
A residual-standard-error channel measures dispersion around the fitted line. A price-standard-deviation channel measures dispersion around the average. Specify the input, statistic and multiplier with the channel.
Linear regression channel example: one close, two fits
The first 20-bar window covers chart bars 2 through 21. Its slope is $0.177 per bar, its residual standard error is $0.36 and its R-squared is 0.90.
At bar 21, the center is $52.41 and the upper band is $53.13. The $53.40 close is $0.27 above that boundary and 2.75 residual standard errors above the center.
After bar 22 closes at $54.30, fit bars 3 through 22. Slope becomes $0.21, residual standard error $0.50 and R-squared 0.86. At the same prior bar, the new upper boundary is $53.73, $0.33 above its unchanged $53.40 close.
The chart preserves both fits so the comparison is visible. A rolling full-window drawing updates its selected historical segment, while a fixed-window drawing retains the same fit for unchanged inputs.
How traders use a linear regression channel
Define the selected decision window and record the fit available at that bar. Specify whether the entry uses a boundary touch, an outside close or a later return, then set invalidation, size and exit.
Normalize slope as 100 × slope / a declared reference price when comparing percentage rates across symbols on the same bar interval. The fitted end-to-end change is slope × (n − 1).
For a scenario h bars beyond the final observation, the fitted line extends by b × h from its final fitted value. Use trading bars for that horizon and supply the options model’s own expiration and volatility inputs. Options Flow shows whether large orders lean with the slope, and the Options Profit Calculator prices each structure at the channel’s projected value for that horizon.
Limitations of linear regression channels
- Record the fit at each decision bar. A rolling channel refits on every bar, so earlier band positions change: the same $53.40 close sits $0.27 outside the first fit and $0.33 inside the refit one bar later.
- The line assumes a straight trend across the window, so curved or reversing paths fit poorly. An R-squared of 0.90 grades the last 20 bars; the trade still needs a stop for the bar where the trend bends.
- Pick the lookback before you test it. A different length gives a different slope and width, and a length tuned to past data carries overfitting into the rule.
- Name the band statistic with the channel. Standard error, price standard deviation and Raff maximum channels give different widths on the same window.
- Extending the line forward projects the fitted slope, so set the target from it and keep the stop at the band in case the trend breaks.
Bottom line
A linear regression channel summarizes a window of prices as a fitted trend line with parallel dispersion bands, reporting pace, spread and fit quality separately. Fix the lookback, price input and band statistic, record the fit available at each decision bar, and set targets from the line’s forward extension with the stop at the band.
Clear answers
Frequently Asked Questions
Sources and Further Reading
- NIST/SEMATECH e-Handbook of Statistical Methods: Linear Least Squares Regression
- NIST/SEMATECH e-Handbook of Statistical Methods: How can I tell if a model fits my data?
- Schwab thinkorswim Learning Center: Regression Channel drawing tool
- Schwab thinkorswim Learning Center: Standard Error Channel study
How entries are sourced, calculated and updated: editorial methodology.