Trend indicator

Linear Regression Indicator (LRI): a faster trend line

The Linear Regression Indicator (LRI) fits a best fit straight line through the last 14 closes and plots the point where that line ends, then repeats on every candle. It hugs price more closely than a 14 period moving average, so it turns sooner. Traders use price crossing the LRI and the LRI's slope (rising or falling) as a quick trend read, with a close back through the line as the point that cancels the idea.

No card for the live chart7 days freeCancel any time

WickSpeak reads it

What it isHow to trade itWhat proves it wrong
Illustration

What it is

Linear regression is the maths behind a best fit line: it finds the straight line that sits closest to a set of points. The LRI does this for the last so many candles and keeps only the end point, the value the line gives for the current candle.

Because a straight line through recent prices already leans in the direction they are travelling, the end point sits close to the latest price. That is why the LRI behaves like a moving average with much less delay. The trade off is that it also reacts to short bursts that a moving average would ignore.

How it is calculated

Take the last n prices (14 closes by default) and number them 0 to 13. Work out the least squares line through them: the slope b is the covariance of position and price divided by the variance of position, and the intercept a is the average price minus b times the average position. The LRI value for this candle is a + b x (n minus 1), the line's value at the newest candle. Repeat on the next candle with the window moved along by one. This is the same value many platforms call the least squares moving average (LSMA).

Settings

SettingDefaultRangeWhat it changes
length142 to 500How many candles the line is fitted through. Shorter follows price very closely; longer is smoother and shows the broader slope.
sourcecloseclose, open, high, low, hl2, hlc3, ohlc4Which price the line is fitted to. Close is standard.

How to read it

LRI rising, price above itThe recent best fit slope points up and price is on the right side of it: short term uptrend.
LRI falling, price below itShort term downtrend; rallies into the line are selling opportunities for trend traders.
Price crosses the LRIThe newest close has moved to the other side of the fitted line. With 14 candles this happens often, so it is an early warning rather than a full reversal.
LRI flattensThe best fit slope is near zero. Momentum has stalled and the market may be turning or ranging.

How to trade it

  1. 1

    Use a slower filter for direction, for example the 50 EMA on a 15 minute US30 chart. Only take LRI signals in that direction.

  2. 2

    Entry trigger: in an uptrend, wait for price to dip below the LRI and then close back above it while the LRI is rising again. Enter on that close.

  3. 3

    Stop below the low of the dip. On US30 at 15 minutes that might be 20 to 40 points; size it to the index's ATR at the time.

  4. 4

    Target 1.5 to 2 times the stop, or exit when a candle closes back below a falling LRI.

What proves it wrong

Two consecutive closes on the wrong side of the LRI while the line turns against you cancel the trade. If the slower trend filter also flips, stand aside.

How WickSpeak reads Linear Regression (LRI)

On WickSpeak, the LRI writes a plain-English reading on the live candle: what it is, whether price is above or below it and whether it is rising or falling, how to trade that, and what would prove it wrong. In Playbook you can test it without code: price crosses above it, price crosses below it, price is above it, price is below it, it is rising, or it is falling. Any of those can be combined with up to 11 other conditions and backtested on past candles with your costs.

Best markets and timeframes

The LRI suits fast, directional markets such as NAS100, US30 and gold on 1 to 15 minute charts, where its quick turn matters. On slow, choppy forex pairs it flips too often unless the length is raised to 30 or more.

Common mistakes

  • Reading every cross as a reversal. With a short length the LRI crosses price many times a session.
  • Confusing the LRI with a regression channel. The LRI is one line through the end points; a channel draws the whole fitted line with bands either side.
  • Using it alone in a range, where its quick turns produce a loss on almost every flip.

Works well with

Questions traders ask

What is the difference between linear regression and a moving average?

A moving average is the average of past prices, so it sits behind price when the market trends. Linear regression fits a sloped line through the same prices and takes its end point, so it stays much closer to the latest price and turns sooner.

Is the LRI the same as LSMA?

Yes, in most platforms the least squares moving average and the linear regression indicator give the same value: the end point of the least squares line over the chosen length. Some versions add an offset setting that shifts the line.

What length should I use for the linear regression indicator?

14 is the default and suits intraday charts. Raise it to 25 or 50 if it flips too often on your market, and test the change over many trades rather than a handful.

Does the LRI repaint?

The value for a closed candle does not change, because each point is fitted only to candles up to that one. The value on the live candle moves until the candle closes, as with any indicator built from the close.

Read Linear Regression (LRI) on a live chart

WickSpeak writes what Linear Regression (LRI) is doing on every candle, how to trade it and what proves it wrong. Free for 30 minutes, no account.