Trend & direction

Least Squares Moving Average · LSMA

The endpoint of a rolling linear regression line — a moving average that leans into the trend to cut lag.

Works best in trending marketsEngine-computed on a fixed sample series
14512096Price above EMA 12 = strengthPrice below EMA 12 = weaknessEMA 12 acts as support / resistance
EMA 12EMA 26How to read LSMA on the chart — the callouts mark what to look for.

The formula

LSMA is the endpoint of a rolling linear-regression line — the regression's best estimate of where price is right now. Because it accounts for the slope of recent data, it hugs price with less lag than an SMA.

Fit y = a + b·x through the last N closes by least squares, then plot a + b·N (the line's value at the newest bar)
Worked example
Bar (x)Price (y)x × y
110101
211224
312369
4135216
5157525
Σ = 156119555

Slope = 1.2, intercept = 8.6 → LSMA endpoint = 8.6 + 1.2 × 5 = 14.6 (SMA = 12.2)

What it is

The Least Squares Moving Average, or LSMA, is a moving average that reduces lag by fitting a straight line to recent prices and plotting where that line ends, rather than simply averaging the prices. It goes by several names, including the linear regression curve and the endpoint moving average, all describing the same idea. A simple moving average treats every past price with equal weight and always trails behind, but the LSMA accounts for the slope of recent data, so when price is trending it projects the regression line forward to its current endpoint and hugs price far more tightly. For a beginner, imagine drawing the best-fit straight line through the last several weeks of price and marking today's point on that line; the LSMA connects those points into a low-lag trend curve. The result is a moving average that leans into the trend and reacts a few bars sooner than a conventional one.

How it is calculated

For each bar the LSMA performs a linear regression over the last N prices, using the method of least squares, which finds the straight line that minimizes the total squared vertical distance between the line and the actual prices. That regression produces a slope and an intercept describing the best-fit trend of the window. Instead of plotting the whole line, the LSMA plots only its value at the most recent bar, the endpoint of the fitted line, which is the regression's best estimate of where price should be right now given the recent trend. Because this endpoint incorporates the slope, it sits ahead of where a simple average of the same prices would sit whenever price is trending. As each new bar arrives, the regression is recomputed over the shifted window and the new endpoint is plotted, tracing out the LSMA curve.

Reading it, step by step

Read the LSMA as a responsive trend line: when it is rising and sits below price, the trend is up and healthy, and when it is falling and sits above price, the trend is down. Its slope is the trend direction, and because the LSMA lags less than an SMA, a change in that slope arrives earlier as an advance warning of a turn. Crossovers of price through the LSMA, or of a fast LSMA through a slow one, occur several bars before the equivalent SMA crossovers, giving earlier entries and exits. The tight way the LSMA tracks price also makes it a useful dynamic support and resistance line in a trend. Be alert, though, that the same low-lag responsiveness makes the LSMA prone to hooking sharply, so a sudden change in its slope during choppy conditions can be a false alarm rather than a genuine turn.

Reading the signals on the chart

14512096
EMA 12EMA 26The ▲/▼ 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 +

A 25-period LSMA is a popular default; shorter lengths track price aggressively.

LSMA vs plain averages

LSMASMAEMA
Projects the slopeYesNoNo
LagLowHighMedium
Overshoot in chopYesNoSome

Common price-action setups

How the signal typically plays out on the chart.

Price crosses LSMA

Price closes above a rising LSMA a few bars earlier than it would cross an SMA — enter long with a stop below the line or the last swing.

Buy the cross
Early trend entry
Ride the slope

While LSMA rises below price, stay long and buy shallow dips back to the line; exit when the LSMA flattens or hooks down.

Ride the trend
Trend continuation
Price crosses down

Price closes below an LSMA that has turned lower — take the early exit or short, with a stop above the line.

Sell the cross
Trend turns down

Best timeframes and settings

A twenty-five period LSMA is a widely used default that balances responsiveness and stability, and it works well on daily swing charts. Because it is simply a regression endpoint, it adapts to any timeframe, and intraday traders use shorter lengths for quicker signals. Shortening the length makes the LSMA track price aggressively and react almost immediately, which is powerful in a clean trend but produces frequent hooks and false turns in noise. Lengthening it smooths the curve and steadies the trend read at the cost of the early-signal advantage that is the whole point of the tool. The core trade-off mirrors every moving average, but the LSMA sits toward the low-lag, higher-overshoot end of the spectrum, so choosing the length is really choosing how much overshoot you can tolerate in exchange for lead time.

When and where to use it

The LSMA is a trend tool and shines in trending markets, where its low lag lets you capture more of each move than a lagging average would. It applies across all liquid asset classes, since linear regression makes no assumption about the instrument. It is most valuable as a drop-in replacement wherever you would use a moving average for trend direction or dynamic support and resistance, gaining a few bars of lead time. In a sideways, choppy market its responsiveness turns against it, producing whippy hooks and false crossovers as the regression endpoint reacts to noise. Use it when you want early trend signals and are trading an instrument capable of sustained directional moves, and be cautious deploying it in a tight range.

Strategies that use it

The simplest strategy substitutes the LSMA for a standard moving average in a trend-following system, taking longs when price closes above a rising LSMA and exiting on a close back below, benefiting from the earlier signals. A dual-LSMA crossover approach runs a fast and a slow LSMA and trades their crosses, which fire ahead of the equivalent SMA crosses. A pullback strategy treats the rising LSMA as dynamic support in an uptrend, buying dips that hold the line with a stop just beneath it and targeting a continuation of the trend. Because the LSMA is a regression endpoint, some traders also watch the slope of the underlying regression as a momentum confirmation, only taking long entries while both price is above the LSMA and the LSMA slope is positive.

Combining it with other indicators

The LSMA pairs well with a momentum oscillator such as the RSI or the MACD, which confirms that a price-versus-LSMA crossover carries force rather than being a noise-driven hook. A trend-strength gauge like the ADX helps distinguish the trending conditions where the LSMA excels from the ranges where it whipsaws. Because the LSMA can overshoot, a volatility band such as Keltner Channels provides context for how stretched price is relative to the trend. It also complements a linear-regression channel naturally, since both derive from the same least-squares fit, letting you use the channel rails for entries around the LSMA centerline. The guiding idea is to confirm the LSMA's early signals with independent momentum or regime information so you are not acting on every hook.

Where it fails

The LSMA's reduced lag is bought with more overshoot, so its greatest weakness is a tendency to hook sharply and issue false turns in choppy conditions, catching traders who trust its every wiggle. A single outlier bar can tilt the regression line and distort the endpoint, producing a jerk that does not reflect the underlying trend. Because it responds so quickly, it whipsaws in ranges where a slower average would have stayed calm. It is also nearly identical to the Time Series Forecast, which projects the regression one step further, so pairing the two adds little genuine diversification and can create false confidence from two views of the same math. The defenses are to use an adequate length for the timeframe, to confirm signals with an independent indicator, and to avoid deploying it in obvious sideways chop.

A worked example

A stock trends upward and you plot a twenty-five period LSMA alongside a twenty-five period simple moving average. Price pulls back from forty to thirty-seven, and the LSMA, being low-lag, flattens and turns down two bars before the SMA does, warning you early that momentum is cooling. When buyers return and price closes back at thirty-eight, the LSMA hooks upward and price crosses above it a full three bars before it crosses the still-lagging SMA. You enter long at thirty-eight, ahead of traders using the SMA, and place a stop at thirty-six-fifty just beneath the rising LSMA, which now acts as dynamic support. Price resumes its climb to forty-four, and you trail your stop along the LSMA, exiting on a decisive close back below the line, having captured extra profit thanks to the earlier signal.

Common mistakes

  • Chasing its sharp hooks in choppy markets, where the low lag turns into overshoot.
  • Pairing it with the Time Series Forecast and thinking you added a second, independent signal.
  • Forgetting the reading shifts with the lookback length you choose.
  • Treating every little hook as a trend reversal.
  • Letting a single outlier bar tilt the regression and distort the line.