Trend & direction

Linear Regression Slope · LRS

The slope of a least-squares line fitted through recent prices — trend direction and steepness as a number.

Works best in trending marketsEngine-computed on a fixed sample series
14512096Price above SMA 20 = strengthPrice below SMA 20 = weaknessSMA 20 acts as support / resistance
SMA 20SMA 50How to read LRS on the chart — the callouts mark what to look for.

The formula

Over each lookback a straight line is fitted to price by least squares and only its slope is plotted. A positive value means the best-fit line rises (an uptrend), negative means it falls, and the size of the number is how steep that trend is.

Slope = [ N × Σ(x·y) − Σx × Σy ] ÷ [ N × Σ(x²) − (Σx)² ]
Worked example
Bar (x)Price (y)x × y
110101
211224
312369
4135216
5157525
Σ = 156119555

Slope = (5 × 195 − 15 × 61) ÷ (5 × 55 − 15²) = 60 ÷ 50 = 1.2 (positive → rising)

What it is

The Linear Regression Slope, or LRS, distills a trend down to a single number: the slope of the best-fit straight line through recent prices. Where a moving average shows you a trending line, the LRS extracts just the steepness and direction of that line and plots it as an oscillator around a zero level. A positive value means the best-fit line through recent prices is rising, so the market is trending up on average, while a negative value means it is falling, and the size of the number tells you how steep, and therefore how strong, that trend is. For a beginner, imagine repeatedly drawing the best-fit trendline over the last few weeks and, instead of looking at the line, just recording how tilted it is; the LRS is the running record of that tilt. It turns the abstract idea of trend strength into a precise, comparable quantity.

How it is calculated

For each bar the indicator fits a linear regression line to the last N prices using the least-squares method, which finds the line minimizing the total squared distance to the prices. That regression yields two numbers, an intercept and a slope, and the LRS keeps only the slope. The slope expresses how much the fitted line rises or falls per bar across the window, so a slope of plus zero-point-five means the best-fit line is climbing half a price unit per bar on average. As each new bar arrives the regression is recomputed over the shifted window and the new slope is plotted, tracing an oscillator that swings above and below zero. Some implementations normalize the slope, for instance by expressing it as a percentage of price, so that its magnitude can be compared meaningfully across instruments of different price levels.

Reading it, step by step

The sign of the slope gives the trend direction: above zero the best-fit line is rising and the trend is up, below zero it is falling and the trend is down. The magnitude gives the strength, so a large positive slope is a steep, powerful uptrend and a value near zero is a flat, directionless market. Just as important is the change in the slope: a rising slope means the trend is accelerating, while a falling slope that is still positive means an uptrend is decelerating and may be tiring. Zero-line crossings mark the moment the best-fit line flips from rising to falling or vice versa, signaling a change in the average trend direction. Reading the LRS is therefore a two-part act, noting both which side of zero it is on and whether it is moving toward or away from zero.

Reading the signals on the chart

14512096
SMA 20SMA 50The ▲/▼ marks flag where price most recently crossed the line — the cues a trend-follower would act on.

Best timeframes

  • Scalping1m – 5m
  • Day trading5m – 15m
  • Swing1h – daily
  • Positiondaily +

The reading swings with the lookback — keep it fixed while you compare across time.

LRS vs other trend gauges

LRSADXMA slope
Shows directionYesNoYes
Quantifies steepnessYesYesRoughly
Zero-line readingYesNoNo

Common price-action setups

How the signal typically plays out on the chart.

Zero-line cross up

The slope crosses from negative to positive — the best-fit line has tipped upward; enter long, confirming with price structure and a stop below the swing.

Buy zero cross
Trend turns up
Positive and rising

Hold longs while the slope stays positive and is steepening — an accelerating trend; trim or exit as the slope flattens back toward zero.

Ride the trend
Trend accelerates
Zero-line cross down

The slope falls through zero into negative — the fitted line now points down; exit longs or short with a stop above the last high.

Sell zero cross
Trend turns down

Best timeframes and settings

The lookback length is the crucial setting, and it determines how much history the slope reflects, with values around fourteen to twenty-five common for daily swing analysis. A shorter window makes the slope responsive to recent moves, flipping quickly and catching turns early but reacting to minor wiggles, while a longer window produces a steadier slope that reflects the larger trend and changes sign less often. The LRS works on any timeframe because linear regression makes no assumption about the data, so scalpers use short windows on intraday charts and position traders use long windows on weekly charts. Because the reading swings noticeably with the chosen lookback, the same market can appear to have a rising or falling slope depending on the window, so the length should be matched deliberately to the trend horizon you care about. The trade-off is the familiar one of responsiveness against noise.

When and where to use it

The LRS is a trend tool, so it is most useful in trending markets and as a filter to distinguish trending conditions from flat ones. It applies across all liquid asset classes, and its numeric nature makes it especially handy for systematic and quantitative approaches that need trend direction and strength as inputs. It works well as a regime gauge layered beneath an entry system, telling you whether to be looking for longs, shorts, or nothing. In a genuine range the slope hovers near zero and offers little edge, which is itself useful information that says stand aside. Avoid treating small slope readings as meaningful trends, and be aware that a single outlier bar can tilt the regression and briefly distort the slope, so it is best used where price action is reasonably orderly.

Strategies that use it

The most common use is as a trend filter: take long trades from other tools only while the LRS is positive and rising, and short trades only while it is negative and falling, so you never trade against the prevailing best-fit trend. A zero-line strategy trades the crossings directly, going long when the slope crosses above zero and short when it crosses below, which captures changes in trend direction but lags a little because the regression must accumulate enough new data. A slope-momentum strategy watches for the slope to stop rising and begin falling while still positive, using that deceleration as an early warning to tighten stops or take profit before the trend fully reverses. Pairing the LRS with a linear-regression channel is natural, using the slope for the trend read and the channel rails for precise entries.

Combining it with other indicators

The LRS complements price-based entry tools by supplying an objective trend direction, so it is often used to filter signals from oscillators like the RSI or the stochastic, taking only those that align with the slope. It pairs with a trend-strength gauge such as the ADX or the Random Walk Index, and agreement between them raises confidence that a real trend exists. Because it derives from the same regression as the linear-regression channel and the least-squares moving average, it slots neatly alongside those tools to form a regression-based trading framework. Volume and momentum indicators help confirm that an accelerating slope is backed by genuine participation. The recurring principle is to let the LRS answer which way and how strongly the market is trending, while other tools handle the precise entry and exit.

Where it fails

As a fitted average, the LRS lags turns, so it confirms a change in trend after the regression window has absorbed enough new bars rather than at the exact reversal. The reading swings with the chosen lookback, so an ill-suited window can make a market look trending when it is really just noisy, or flat when a real move is starting. A single outlier bar, such as a gap or a spike, can tilt the regression line and briefly distort the slope, producing a misleading jump. In choppy markets the slope oscillates around zero and its crossings whipsaw. The defenses are to choose a lookback matched to the horizon you trade, to confirm slope signals with an independent trend or momentum indicator, and to treat readings near zero as no-trend rather than forcing a directional interpretation onto them.

A worked example

You trade a stock on the daily chart with a twenty-period Linear Regression Slope as a filter beneath an RSI pullback system. For weeks the slope has been solidly positive at plus zero-point-eight, confirming a strong uptrend, so you only look for long entries. Price pulls back and the RSI dips to thirty-three, and because the slope is still positive, you take the long, entering at sixty with a stop at fifty-seven. As price resumes higher the slope climbs to plus one-point-one, telling you the trend is accelerating, so you hold with confidence. Weeks later, near seventy, the slope stops rising and begins to fall while still positive, decelerating from plus one-point-one toward plus zero-point-three, an early warning that the trend is tiring, so you tighten your stop and exit near sixty-nine before the slope finally crosses below zero and the uptrend rolls over.

Common mistakes

  • Expecting it to call turns early — as a fitted average it lags the actual reversal.
  • Comparing readings without keeping the lookback fixed, since it swings with the window.
  • Letting a single outlier bar tilt the slope.
  • Trading tiny slope wiggles around the zero line as if they were real signals.
  • Using the slope alone without confirming against price structure.