Help Center

Regression

Linear regression fits the straightest line through the last N bars of price. The four indicators in the Regression group each report a different part of that line. They show where it ends, how steep it is, where it starts and how well price fits it.

Category Trend and structureApplies to Web and DesktopUpdated 2 Nov 2026Read time 3 min
Shows
A line on the price chart, or a line in its own panel
Updates
On every bar update, over the last N bars
Best on
Any time chart
ES on a 3-minute chart with LinearRegression added. The panel under the candles plots the R2 value, which stays between 0 and 1.ES on a 3-minute chart with LinearRegression added. The panel under the candles plots the R2 value, which stays between 0 and 1.
ES on a 3-minute chart with LinearRegression added. The panel under the candles plots the R2 value, which stays between 0 and 1.

How it is calculated

For the last Periods bars, the indicator finds the line that sits closest to the chosen price in a least-squares sense. That line has a slope and an intercept. The R2 value says how closely price follows the line.

Line: price = intercept + slope × bar number

When a new bar arrives, the window moves forward by one bar and the line is fitted again.

Add a regression indicator

  1. In the chart header, click Indicators.
  2. Under Add Indicator, open the Regression group, or type LinearRegression in Search indicators.
  3. Click the name. It is added to the chart and its settings open on the right.

You can add the same indicator more than once, for example two slopes with different periods. See Add and manage indicators for hiding, reordering and removing indicators.

The indicators

The names below are the names in the indicator list. Each starts with a period of 14 bars and the close as its source.

NameWhat it showsDraws
LinearRegressionForecastThe value the regression line projects for the current bar. It shows how far price has moved from where the trend line expects it.Price chart
LinearRegressionThe R2 value (coefficient of determination), from 0 to 1. A value near 1 means price follows a straight line closely. A value near 0 means there is no clear linear trend.Own panel
LinearRegressionInterceptThe value of the regression line at the start of the window, where the bar number is zero.Price chart
LinearRegressionSlopeThe slope of the line, in price per bar. Above zero is an up trend. Below zero is a down trend. A larger number means a steeper trend.Own panel

The Oscillator group also has TSF (Time Series Forecast), CFO and FOSC. They use the same regression line.

Settings

LinearRegression selected in the Indicators window, with its settings on the right.LinearRegression selected in the Indicators window, with its settings on the right.
LinearRegression selected in the Indicators window, with its settings on the right.

Each indicator opens a Settings group.

SettingWhat it does
PeriodsHow many bars the line is fitted to. The default is 14. Longer periods give a smoother, slower line.
SourceThe price the line is fitted to: Open, High, Close, Volume, Weighted, Typical or Median. The default is Close.
Line ColorColor of the line.
Line WidthThickness of the line.
Line StyleSolid, Dash, Dot or Dash-Dot.
Line EnabledSwitch that hides or shows the line.

To start every new copy of an indicator with your settings, click the save icon at the bottom of the settings and choose Save as Default Template.

How traders read it

  • Slope sign: positive slope means the fitted trend is up over that window, and negative means down.
  • Slope getting smaller: the trend is flattening, even if price has not turned yet.
  • R2 near 1: price is trending cleanly. Trend-following setups tend to suit this state.
  • R2 near 0: price is choppy. Trend signals are less reliable.
  • Forecast against price: price far above the forecast line means the last bars moved faster than the trend. Price far below it means the opposite.

Tip. Use R2 as a filter. Check the slope for direction only when R2 shows that the trend is clean.

Was this article helpful?