Technical analysis

Linear Regression Channel and Standard Deviation Bands

A linear regression channel is a straight least-squares line fitted to a window of closing prices, with two parallel bands set a chosen number of standard deviations above and below it. The line is recalculated as the window moves, so the channel describes past prices only.

By RTX5 Editorial TeamLast updated: Editorial methodology
Plot of five EXAMPLE closes at bars 1 to 5 with a fitted least-squares line (slope 1, intercept 9), dashed bands at plus and minus 2.309, and amber residual lines, beside cards showing the slope, intercept, residual spread and the bar 5 band from 11.69 to 16.31.
Illustration with five EXAMPLE closes, not market data. At k = 2 the bands sit 2.309 price units either side of the fitted line. Open full-size diagram (opens in a new tab)

In brief

What is a linear regression channel?

A linear regression channel is a fitted line with bands on either side. Here are the least-squares formulas, a five-bar worked example, and why platforms draw different channels from the same closes.

Key takeaways

  • A linear regression channel is a least-squares line through the closes in a window, with bands at plus and minus k times the residual standard deviation.
  • The slope is the change in the fitted line per bar. The intercept is the fitted value at bar zero.
  • Platforms can differ on the window length, the deviation multiplier and the divisor used for the spread, so read the settings before comparing charts.
  • The channel is refitted as the window moves, so a channel drawn earlier can look different later. It describes past closes and forecasts nothing.
  • The worked example uses five EXAMPLE closes. It gives a slope of 1, an intercept of 9 and a band of plus or minus 2.309 at k = 2.

How a linear regression channel is built

A linear regression channel starts with a window of recent closing prices. Each bar in the window gets a bar number, x, and its close is y. A least-squares straight line is fitted through those points. The fitted line is the centre of the channel, and its slope shows the direction of the window's trend.

Each close sits some distance from the line. That distance is a residual. The residual standard deviation summarises the residuals, and each band sits a chosen number of residual standard deviations above and below the fitted line. For lines drawn by hand instead, see how to draw trendlines.

The NIST/SEMATECH e-Handbook of Statistical Methods describes least-squares estimation as minimising the sum of the squared deviations between the data and the model. For a straight line, that principle gives the formulas below.

The formulas: slope, intercept and band width

The formulas follow the NIST/SEMATECH e-Handbook for a straight line, y = b0 + b1 x, fitted to n observations.

  • Slope: b1 = sum of (x minus mean x) times (y minus mean y), divided by the sum of (x minus mean x) squared.
  • Intercept: b0 = mean y minus b1 times mean x.
  • Residual: the close minus its fitted value, where the fitted value is b0 plus b1 times x.
  • Residual standard deviation: s = the square root of (the sum of squared residuals, divided by n minus 2). NIST's handbook divides by n minus p, where p is the number of model parameters, and writes the estimate as sigma-hat. For a straight line p = 2, so the divisor here is n minus 2.
  • Band: upper band = fitted value plus k times s; lower band = fitted value minus k times s, where k is the deviation multiplier.

TradingView's help article on its Regression Trend tool describes bands set a user-defined number of standard deviations from a base line, with separate upper and lower deviation inputs. It does not state default values. The choice of k is a setting, not a rule.

Worked example: five closes and one band

This is an Example with made-up numbers, not market data. Five closes sit at bars 1 to 5: 11, 10, 12, 12 and 15. The mean bar number is 3 and the mean close is 12.

Example: least-squares workings for five closes
Bar (x)Close (y)x minus 3y minus 12ProductFitted valueResidualResidual squared
111-2-121011
210-1-2211-11
3120001200
41210013-11
5152361411
Sum6000106004

Example arithmetic. Mean x = 3 and mean y = 12. The values are a teaching case, not a recommended setting.

Slope. The products add to 10, and the squared x deviations also add to 10. So b1 = 10 divided by 10 = 1. The fitted line rises by 1 close for each bar.

Intercept. b0 = 12 minus (1 times 3) = 9. The fitted line is 9 plus x, with fitted values of 10, 11, 12, 13 and 14.

Residual standard deviation. The residuals are 1, -1, 0, -1 and 1. Their squares add to 4, and they sum to zero. With n minus 2 = 3, s = the square root of (4 divided by 3), about 1.1547.

Band at k = 2. The half-width is 2 times the square root of (4 divided by 3), which is 2.3094 to four decimal places, so it rounds to 2.309. At bar 5 the fitted value is 14, so the band runs from 11.69 to 16.31, and the close of 15 sits inside it. The multiplier of 2 is a choice for this example, not a recommended value.

Where platforms differ

Channel names, defaults and inputs are not standard. The same closes can produce different bands on two platforms, because the window, the multiplier and the divisor in the spread can each change. For example, the NIST-based formula on this page divides by n minus 2 (n minus p, with p = 2 for a straight line), while StockCharts' Standard Deviation indicator, a separate volatility measure, is calculated for a population.

Variants that change a linear regression channel
ItemVariant oneVariant twoWhat to check
Divisor for the spreadn minus p in NIST's handbook, where p is the number of parameters. For a straight line p = 2, so n minus 2 (used here)Not named in the TradingView article checked. Check each platform's documented formulaA different divisor gives different band widths from the same closes.
Default lengthNo default is stated in the TradingView article checkedStockCharts' Slope indicator uses 20 periods by default. It is a separate calculation, not a channel defaultRead the settings dialog of the platform you use.
Deviation multiplierTradingView's Regression Trend tool has separate Upper and Lower Deviation inputsThis page uses k = 2 only as a worked choice, not a defaultUpper and lower multipliers can differ, so check both.
Spread basisResiduals of the closes from the fitted line (NIST, used here)TradingView's Regression Trend article sets bands a user-defined number of standard deviations from a base line, and does not say how that base line is computedRead the platform's help or script source before comparing tools.

Sources: StockCharts ChartSchool pages on Standard Deviation and Slope, the TradingView Regression Trend help article, and the NIST/SEMATECH e-Handbook. The StockCharts pages describe related indicators. The Slope page mentions the Raff Regression Channel, an annotation tool with a regression line in the middle and equidistant outer lines, but gives no formula for it.

StockCharts' Standard Deviation indicator is a separate volatility measure, not a channel, so this guide does not use it.

Before you compare two charts, match the length, the multiplier and the divisor. For a channel built from highs and lows rather than a fit, see Donchian and Keltner channels.

Why the channel is redrawn as the window moves

A rolling linear regression channel uses the last N closes. When a new bar closes, the window shifts, the fit is run again, and the bands move with it. A channel drawn earlier can look different once more bars arrive.

Before you use a platform's channel to review past charts, check how it refits the line, and whether a past bar changes when new bars arrive.

A channel drawn with fixed anchor points does not refit this way. Support and resistance covers price levels, which follow no fitted arithmetic.

How the bands are read, and what they do not show

A band describes distance. A close near the upper band sits far above the fitted line, measured in units of the window's residual spread. It does not say whether price will continue, reverse or stall.

  • A close outside the band is an unusual distance from the fitted line for that window. It is not a signal on its own.
  • The slope describes the average direction of the window only. It does not show support, resistance or the cause of a move.
  • Two channels with the same slope can have very different bands when their residuals differ.

Limits of a linear regression channel

  • It describes past closes. It does not forecast, and it gives no win rate or expected return.
  • The window length matters. A short window reacts to noise, and a long window lags turns and can span several regimes.
  • A straight line fits poorly when the window holds a curve, a gap or a change of regime. The residual spread then mixes the trend with the break.
  • The share of closes inside a band depends on how the residuals are spread. This guide does not measure that spread for any market, so do not assume a fixed share of closes sits inside a band.
  • Judging a refitted channel on the same past data it was fitted to can look better than real-time use, because each past bar is judged with a line that used later bars.

Risk disclosure

  • This page is educational and is not personal financial advice. Trading involves a risk of loss, and the example numbers are illustrative only.
  • A linear regression channel describes past closes. It does not show future prices, and a close touching a band is not a trade signal by itself.
  • The window length, the deviation multiplier and the divisor change the bands. Two platforms can draw different channels from the same data.
  • A refitted channel can look more accurate in hindsight than it was in real time. Judge any channel only on data you recorded as it happened.
  • Band edges are not stop-loss prices. Stop placement depends on the order type and on how the broker triggers it. See what is a stop-loss order.

RTX5 status

This guide explains linear regression channels in general and does not describe an RTX5 feature. No RTX5 release record confirms which indicators, chart types or alerts the product includes. Its Windows desktop client is in preview, and the web and mobile clients are planned. A Google Play listing for Android is published, but the mobile client has no approved release record yet; check the product-availability record before relying on any RTX5 feature.

Check RTX5 product availability

Trust and methodology

How this research was prepared

We want you to be able to identify who owns the page, inspect the evidence, understand how tools were used, and challenge anything that looks wrong or out of date.

Accountable publisher

Published under the RTX5 Editorial Team byline. It identifies the responsible publishing organization; it does not imply that a named lawyer, regulator, financial adviser, or licensed expert approved this page.

Evidence you can inspect

6 primary references are listed on this page with context about what each one supports. The source set was checked on .

Assistance is disclosed

Automation and AI may help organize research, outline a page, or edit language. They are not treated as sources, are not presented as human experts, and do not remove the publisher's responsibility for the final page.

Primary references

Sources were checked on 10 November 2026. They explain market rules and concepts; they do not certify RTX5 or provide individual financial advice.

Questions readers ask

What is the difference between a linear regression channel and a standard deviation channel?

Platforms use the names differently, so check each tool's formula. Here, a linear regression channel is a least-squares line with bands at k times the residual standard deviation. Read the help page before comparing them.

How many bars should a linear regression channel use?

No single length is standard. StockCharts' Slope indicator uses 20 periods by default, but that is a different calculation. A short window reacts to noise, while a long one lags turns. Pick a length, record it, and keep it the same across charts before you compare results.

Does a linear regression channel predict where price will go?

No. The channel describes the closes in a past window and is recalculated as new bars arrive. It does not forecast price, and a close touching a band is not a signal by itself. Use it to describe how far recent closes sit from a fitted line.

What is the residual standard deviation?

It is the typical distance of the closes from the fitted line. NIST's handbook divides the sum of the squared residuals by n minus p, the number of parameters, then takes the square root. For a straight line p = 2, so this guide uses n minus 2. A residual is a close minus its fitted value.

Why does the same channel look different on another platform?

The window length, the deviation multiplier, the divisor in the spread and the way the platform refits the line can all differ. The same five closes can therefore produce two sets of bands. Compare the inputs first, and read the platform's help page for the exact formula.

Can I place a stop-loss order at the channel band?

A band is a reference for distance from the fitted line, not a broker instruction. Where a stop goes depends on your plan, the order type and how your broker triggers stops, and a stop can fill away from its trigger in fast markets. Read the stop-loss guide before you place an order.