How it works
A linear regression channel fits the single straight line that best describes the last N closes, in the specific sense of minimising the sum of the squared vertical distances between the line and the prices. Two parallel lines are then drawn above and below it at a chosen multiple of the deviation of price from that fit. The result is a statistical description of the trend: a centre line for direction, and a band for how much noise the market has been generating around it.
What separates it from a moving average is the shape of the estimate. An average of the last 100 closes is a single number that lags the middle of its window by roughly half its length. A regression through the same 100 closes produces a slope as well as a level, and its endpoint sits at the fitted value for today rather than for fifty bars ago — so it hugs the current price far more closely while still being computed entirely from the window. The slope is a direct, interpretable measure of the trend: price change per bar.
Traders use it three ways. The slope tells you the direction and pace of the trend in units you can actually reason about. The channel edges act as reversion references — in a well-behaved trend, price oscillates between them and touches of the outer line tend to be followed by a return toward the middle. And the goodness of fit, often shown as Pearson’s R, says whether the straight-line description is even appropriate: a high R means an orderly trend, a low one means the channel is being drawn through noise and its edges mean very little.
The important caveat is that the channel is anchored to a window, so it redraws as new bars arrive. Draw a 100-bar regression today and again next week and the lines will have moved, which means the levels are not fixed like a horizontal support. Traders who need a stable channel either anchor the regression to a chosen swing point and leave the start fixed, or accept that they are reading a rolling estimate.
Against its neighbours, it is the parametric cousin of Bollinger Bands: both use a standard deviation to set band width, but Bollinger measures deviation around a flat moving average while the regression channel measures it around a sloped fit, which is a much better description of a trending market. Standard Error Bands take the same idea and scale the width by the standard error of the regression instead.
Calculation
The arithmetic in words, in the order it happens.
Fit a least-squares line to the last N values of the source, with bar index as the independent variable. The slope is the covariance between index and price divided by the variance of the index, and the intercept places the line so it passes through the mean of both. The centre line is that fitted line. Deviation is computed from the residuals — the vertical distances between each price and the fit — and the upper and lower channel lines are drawn a chosen multiple of that deviation above and below the centre. Some implementations use the standard deviation of the residuals, others the largest residual in the window, which produces a wider channel that touches the extremes exactly.
Source
An AlgoBeamScript implementation of the formula above, written by us from the arithmetic so the code and the calculation agree line for line.
Runs unchanged on the platform and in the AlgoBeamTS runtime. The language reference is in the documentation.
Inputs
Defaults are the values most charting packages ship with. They are conventions, not optimal settings — the right length depends on your instrument and your holding period.
| Input | Default | What it changes |
|---|---|---|
| Length | 100 | How many bars the line is fitted through, and the single choice that determines everything you see. A short window fits the latest swing; a long one fits the primary trend and will ignore a multi-week counter-move entirely. |
| Upper deviation | 2 | Multiple of the residual deviation used for the upper line. Two is conventional; wider settings capture nearly all price action and mark only genuine excursions, narrower ones are touched constantly. |
| Lower deviation | 2 | The same multiple for the lower line. It is exposed separately because some traders deliberately run an asymmetric channel to reflect a directional bias. |
| Source | Close | The series the line is fitted to. Fitting to closes gives the cleanest statistical read; fitting to highs or lows produces a channel that hugs one side of the range. |
How to read it
What practitioners take from the plot. Read these as descriptions of market state, not as entry signals.
- Steep centre line with a tight channel
- An orderly, persistent trend: price is advancing steadily and staying close to its own fit. The most favourable structure for trend continuation tactics.
- Price touching the lower channel in a rising channel
- A pullback to the statistical low end of an uptrend. A reversion reference, valid only while the channel itself keeps its upward slope.
- Price closing outside the channel and staying there
- The straight-line description has broken. Either the trend has accelerated into a new regime or it has reversed; in both cases the current fit is stale.
- Flat centre line with a wide channel
- No trend and plenty of noise. The regression is fitting a range, and the channel edges are simply the top and bottom of that range.
- Low goodness of fit
- Price is not behaving like a straight line at all. Slope and channel width are both being computed from data that does not support the model, and neither should be traded.
Limitations
Where this indicator misleads. None of these are fixed by a better parameter.
- The channel repaints as the window rolls. Levels that look like clean support in hindsight were in a different place when the bar actually printed, which flatters every visual backtest of this tool.
- It imposes a straight line on a series that is rarely straight. In an accelerating or decelerating trend the fit is wrong at both ends of the window, and price will sit outside the channel for long stretches for purely geometric reasons.
- The deviation band inherits the usual problem with standard deviations of returns: the estimate comes from a small window of fat-tailed, serially correlated data, so excursions beyond two deviations are far more common than the normal-distribution intuition suggests.
- Results are extremely sensitive to the chosen length and, for anchored versions, to the chosen start bar. Two traders analysing the same chart with different windows will draw contradictory channels and both will look convincing.
Educational reference. This page explains how an indicator is built and how it is commonly read. It is not investment advice, not a recommendation and not a signal service. No indicator is profitable on its own — each is a way of describing a market, and any rule built on one has to be tested with realistic costs before it is traded.