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
| Setting | Default | Range | What it changes |
|---|---|---|---|
| length | 14 | 2 to 500 | How many candles the line is fitted through. Shorter follows price very closely; longer is smoother and shows the broader slope. |
| source | close | close, open, high, low, hl2, hlc3, ohlc4 | Which price the line is fitted to. Close is standard. |
How to read it
How to trade it
- 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
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
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
Target 1.5 to 2 times the stop, or exit when a candle closes back below a falling LRI.
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.
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.