Home / Wiki / L / Linear Regression Indicator

Linear Regression Indicator

Trading and SpeculationUpdated 16 Nov 2026

The linear regression indicator is a tool of technical analysis that is plotted over prices like a moving average. For each bar on the chart, it fits a straight line to the closing prices of the most recent nn bars by the method of least squares and records the value of that line at the latest bar. The fit is repeated as each new bar arrives, and the recorded values are joined into a continuous line.

The indicator is used to identify and follow trends. It is known by several names, including the linear regression curve, the least squares moving average and the end point moving average. It is distinct from a linear regression line, which is a single straight line drawn through a fixed stretch of data. The indicator curves because it is made up of the end points of many such lines, each calculated over a different window.

01

Calculation

Number the bars in the window x=1,2,…,nx = 1, 2, \dots, n, and let yy be the closing price of each. Linear regression finds the line y=a+bxy = a + b x that minimizes the sum of squared vertical distances between the line and the prices. The slope and intercept are:

b=n∑xy−∑x∑yn∑x2−(∑x)2b = \frac{n \sum xy - \sum x \sum y}{n \sum x^2 - \left( \sum x \right)^2}
a=∑y−b∑xna = \frac{\sum y - b \sum x}{n}

The indicator value is the height of the line at the last bar:

LRI=a+b×nLRI = a + b \times n
  • bb is the slope, the average change in price per bar over the window.
  • aa is the intercept, the value of the line one bar before the window begins.
  • nn is the number of bars, with 14 a common default.
02

Worked example

Take five closing prices: 10, 11, 12, 11 and 13. Then ∑x=15\sum x = 15, ∑y=57\sum y = 57, ∑x2=55\sum x^2 = 55 and ∑xy=10+22+36+44+65=177\sum xy = 10 + 22 + 36 + 44 + 65 = 177. The slope is (5×177−15×57)/(5×55−225)=30/50=0.6(5 \times 177 - 15 \times 57) / (5 \times 55 - 225) = 30 / 50 = 0.6. The intercept is (57−0.6×15)/5=9.6(57 - 0.6 \times 15) / 5 = 9.6. The indicator value is 9.6+0.6×5=12.69.6 + 0.6 \times 5 = 12.6.

The simple moving average of the same five prices is 57/5=11.457 / 5 = 11.4. The regression value is higher because it projects the upward drift of the window to its final bar, while the average reflects the level at the middle of the window.

03

Interpretation

The indicator is read much like a moving average. A rising line indicates an upward trend and a falling line a downward one. Prices crossing the line, or the line turning from down to up, are treated as possible signals of a change. Two lines of different lengths can be used together as in a moving average crossover.

Its distinguishing feature is reduced lag. A simple average of nn bars describes the price level roughly half a window ago. The regression value estimates where the fitted trend stands now. In a steady trend it therefore stays closer to current prices than an average of the same length, and it turns sooner after a reversal.

The value can also be seen as a statistical estimate of where price ought to be if the recent trend holds. Some traders treat a large gap between price and the line as a sign that the market is stretched and may fall back toward it, an application of mean reversion. Extending the fitted line one bar ahead gives a related indicator usually called the time series forecast.

Each rolling fit yields other statistics that are plotted in separate panels. The linear regression slope shows the direction and steepness of the fitted line. The linear regression intercept shows where the line starts. R-squared measures how closely prices cluster around the line and is used to judge whether a trend is strong enough to act on. A linear regression channel places parallel lines above and below a fixed regression line, often at a set number of standard deviations.

05

Limitations

Faster response comes at a price. Because it extrapolates the recent slope, the indicator overshoots when a trend ends abruptly, and in a sideways market it swings back and forth more than a moving average, producing more false signals. A single extreme price near either end of the window can tilt the fitted line noticeably.

The statistical assumptions behind regression analysis do not hold well for prices. Successive prices are not independent observations scattered around a fixed line, and the fitted trend has no necessary tendency to continue. The indicator therefore describes the recent past in a compact way and does not forecast in any reliable sense. The choice of window length changes the results considerably, and settings selected through backtesting are exposed to overfitting. It is normally used with other technical indicators and with risk controls.

Last updated 16 Nov 2026