Least Squares Moving Average (LSMA)

LSMA
Indicator

TrendOn the price chartFree on ChartLabs

The Least Squares Moving Average fits a straight line to the last 25 closes and plots where that line ends, on the current bar. It follows price closely.

Moving linear regression, as described by Tushar Chande and Stanley Kroll, The New Technical Trader, 1994. Reviewed by the ChartLabs team, updated Nov 2026.

Example market1hIndicatorsAtlas AILSMAchartlabs.co/charts
Atlas reads it

Price is under a falling LSMA 25. The 25-bar fit points down.

LSMA 25 65,634.8 · Close 65,242.2

Atlas reads it

Price is under a falling LSMA 25. The 25-bar fit points down.

LSMA 25 65,634.8 · Close 65,242.2

Illustration on simulated data.

Least Squares Moving Average (LSMA)What is the LSMA indicator?

LSMA draws one blue line on the price chart. Each bar it finds the straight line that best fits the last 25 closes, by least squares, and plots the value of that line on the newest bar.

A simple moving average equals the same fitted line read in the middle of its window, about 12 bars back for a length of 25. LSMA reads the line at its newest end instead, so in a steady trend it trails price far less.

The cost is that it bends harder. After a sharp reversal the line keeps some of the old slope for a few bars, and in a range it wiggles more than an SMA of the same length.

Offset

Offset 0 reads the line on the newest bar. A positive offset reads it that many bars back; a negative offset reads it ahead of the newest bar.

Warm-up

The fit needs 25 closes, so the first value is on the 25th bar. Earlier bars are left empty.

LSMA signalsFive patterns to know.

1Bullish

Price above a rising LSMA

Closes stay above a line that climbs.

2Bearish

Price under a falling LSMA

Closes stay under a line that falls.

3Bullish lean

Close back above

After a run of closes under the line, price closes above it and holds there.

4Bearish lean

Close back under

After a long run above, price closes under the line and stays there.

Many crosses, no trend
5Inconclusive

Crossed both ways

Price crosses the line again and again while it goes nowhere.

LSMA formulaHow it is calculated.

b=∑(x−x¯)(y−y¯)∑(x−x¯)2a=y¯−bx¯LSMA=a+b×(24−offset)
STEP 1

Number the bars

Give the last 25 closes x values from 0 for the oldest to 24 for the newest.

STEP 2

Fit a line

Find the slope b and the intercept a of the straight line with the smallest sum of squared distances to the closes.

STEP 3

Read its end

Plot the line's value at x = 24, the current bar. With an offset, read it that many bars earlier.

LSMA settingsEvery setting, explained.

SettingDefaultRangeWhat it changes
Length252 to 5,000Closes in the fit. Longer is smoother and slower.
Offset0-5,000 to 5,000Where the line is read: 0 on the current bar, positive values further back, negative values ahead.
SourceCloseAny priceWhich values feed the fit.
LineBlue #2962FF, 1 pxAny colour and widthColour and width of the line.
Setting
Length
Default
25
Range
2 to 5,000
What it changes
Closes in the fit. Longer is smoother and slower.
Setting
Offset
Default
0
Range
-5,000 to 5,000
What it changes
Where the line is read: 0 on the current bar, positive values further back, negative values ahead.
Setting
Source
Default
Close
Range
Any price
What it changes
Which values feed the fit.
Setting
Line
Default
Blue #2962FF, 1 px
Range
Any colour and width
What it changes
Colour and width of the line.
2520 price crosses in view
70,56267,08363,60560,12764,803.7

Drag to see how the setting changes the lines and how many signals you get. Illustration on simulated data.

LSMA strategiesUse it in 3 setups.

Trend filter

Only long whileprice is aboveLSMAandLSMArises

Because the line stays close to price, traders often use it to pick a side and time entries with something faster.

Enter on a close back above

Ifprice closes aboveLSMAafter5closes under it

After a decline, a close back above the fitted line suggests the fall has stalled. Traders often wait for the next closes to hold above it.

Buy a pullback to the line

IfLSMArisesandthe low touches itandthe close holds above

In a steady advance traders often wait for a dip to the line instead of chasing a run.

Test a rule in the Strategy TesterFree with 1 year of history. Past results do not guarantee future results.

LSMA mistakesCommon mistakes.

Through the line and straight back

Acting on every close through it

Price crosses a close-fitting line often. Here a cross was undone within two bars.

Many crosses, no trend

Trading crosses in a range

When the line goes sideways, crosses in both directions mean little.

The lowThe cross comes later

Expecting no lag at all

LSMA lags less than an SMA, but it still lags. Here the close above it came a few bars after the low.

LSMA combinationsPair it with these.

LSMA FAQQuestions traders ask.

What are the default LSMA settings?

Length 25 and Offset 0 on the close, the same as TradingView.

How is the LSMA calculated?

It fits a least-squares straight line to the last 25 closes and plots the value of that line on the current bar.

Why does LSMA lag less than an SMA?

An SMA equals the fitted line read in the middle of the window. LSMA reads the same line at its newest end, 12 bars further along for a length of 25.

LSMA or EMA?

Both react sooner than an SMA. LSMA follows a straight run more closely and bends harder when price turns sharply.

What does the Offset do?

It moves the point where the line is read. 0 is the current bar; 5 reads the line 5 bars back; -3 reads it 3 bars ahead.

Is this the same as the LSMA indicator?

Yes. The indicator list shows one Least Squares Moving Average, and charts saved with the older LSMA entry draw the same line with the same defaults. Linear regression curve is another common name for it.

LSMA or Time Series Forecast?

Time Series Forecast reads a 14-close line 3 bars ahead. LSMA reads a 25-close line on the current bar, so it sits closer to price.

Why does the line start late?

It needs 25 closes before it can fit a line, so it begins on the 25th bar.

Does LSMA work on crypto?

Yes. It works on any market with closes.

Does LSMA repaint?

No. Values on closed bars never change. The live bar moves until it closes.

Related indicatorsMore trend tools.

All trend indicators

Try LSMA on a live chart.
Free. No download.

Works in your browser and on iPhone too.

Example market1h
LSMA (25, 0, close)