LSMA
Indicator
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.
Price is under a falling LSMA 25. The 25-bar fit points down.
LSMA 25 65,634.8 · Close 65,242.2
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.
Price above a rising LSMA
Closes stay above a line that climbs.
Price under a falling LSMA
Closes stay under a line that falls.
Close back above
After a run of closes under the line, price closes above it and holds there.
Close back under
After a long run above, price closes under the line and stays there.
Crossed both ways
Price crosses the line again and again while it goes nowhere.
LSMA formulaHow it is calculated.
Number the bars
Give the last 25 closes x values from 0 for the oldest to 24 for the newest.
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.
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.
| Setting | Default | Range | What it changes |
|---|---|---|---|
| Length | 25 | 2 to 5,000 | Closes in the fit. Longer is smoother and slower. |
| Offset | 0 | -5,000 to 5,000 | Where the line is read: 0 on the current bar, positive values further back, negative values ahead. |
| Source | Close | Any price | Which values feed the fit. |
| Line | Blue #2962FF, 1 px | Any colour and width | Colour 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.
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
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
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
In a steady advance traders often wait for a dip to the line instead of chasing a run.
LSMA mistakesCommon mistakes.
Acting on every close through it
Price crosses a close-fitting line often. Here a cross was undone within two bars.
Trading crosses in a range
When the line goes sideways, crosses in both directions mean little.
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 + SMA
A plain average is the fitted line read in the middle of its window. Side by side, it shows how much less LSMA trails.
LSMA + Linear Regression Slope
The slope of a 14-close fit in its own panel: above zero while the line points up.
LSMA + ADX
ADX shows whether price is trending, which is when a fitted line helps most.
LSMA + ATR
ATR helps size a stop around a line that sits close to price.
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 indicatorsTry LSMA on a live chart.
Free. No download.
Works in your browser and on iPhone too.