Concept
LSMA
LSMA, also known as least-squares MA, linear-regression value, endpoint MA/EPMA, Time Series Forecast/TSF, is a Trend concept. The Library holds 5 implementations, each one a working definition you can pull into Quant.
Top LSMA indicators
5 total
What is LSMA?
LSMA, the least-squares moving average, fits a straight line to the last N closes by ordinary least squares (linear regression) and plots the value of that line at the current bar. Slide the window one bar, refit, plot again: the indicator is the running sequence of regression endpoints, which is why it is also called the endpoint moving average or linear-regression value; the time series forecast is the same fit projected one bar ahead on some platforms. Because a fitted line may tilt, its endpoint can sit beyond every price in the window, something no positively weighted average can do, and that is where its speed comes from.
Two identities make its behavior legible. Algebraically, LSMA = 3 × WMA − 2 × SMA of the same length: it extrapolates the weighted average past the simple one. Written as a single weighted average, its oldest bars carry negative weights, which is what lets the line lead at turns and also why it overshoots after sharp moves and can jump when a large old bar falls out of the window. Responsiveness and overshoot are the same property seen from two sides.
How to calculate LSMA
One regression per bar:
- 1Take the last N closes and fit the least-squares line, the line minimizing the sum of squared vertical distances to those closes.
- 2Record the fitted line's value at the newest bar; that value is the LSMA for this bar.
- 3Shortcut: the same number equals 3 × WMA(N) − 2 × SMA(N), so no explicit regression is needed.
- 4Advance one bar and repeat. Each bar keeps its own window's endpoint, so plotted history does not change.
How traders use it
- As a fast trend line: price/LSMA crossings and slope changes trigger earlier than same-length conventional averages, with the standard toll of extra false starts in chop.
- As the live midline of regression tooling: the linear-regression channel's midline evaluated at the current bar is the LSMA, so distance from it doubles as a stretch measure for reversion trades.
- As a smoother for other series: an LSMA of an RSI or of volume keeps turns sharp where a simple average would round them off, and overshoot matters less on bounded oscillators.
- As a slope proxy: because the endpoint embeds the fitted slope, bar-to-bar change in the LSMA approximates the regression slope without computing it separately.
LSMA vs related tools
Linear Regression: The parent study: the full fitted line drawn across the window and refit live. LSMA is its endpoint only, sampled bar by bar into a non-repainting series.
EMA: All-positive, geometrically decaying weights, so it can only lag price, never lead it. LSMA's negative old-bar weights buy lead time and pay for it with overshoot.
ZLEMA: Chases the same zero-lag goal by momentum-correcting the EMA's input rather than fitting a line. Different mechanism, similar intent; the two react differently to spikes entering and leaving the lookback.
More LSMA implementations
Related concepts · Moving-average lineage
Concept family
Trend
100 concepts mapped · 88 in the Library
LSMA FAQ
Are LSMA and linear regression the same thing?
Same math, different plot. A linear-regression study draws the whole fitted line (or channel) across the lookback and refits it as bars arrive, so the drawing moves. LSMA keeps only the fitted value at each bar's own endpoint and strings those values together, so it reads as a moving average and its history never changes once printed.
Why does LSMA overshoot after sharp moves?
The fit projects the window's slope onto the newest bar, and expressed as a weighted average the oldest bars carry negative weights. After a steep run the fitted slope stays tilted while price stalls, so the endpoint keeps extending before snapping back. The same mechanics let it turn quickly; you cannot keep the speed and remove the overshoot.
What is a good LSMA length?
There is no canonical setting; platform defaults vary. Shorter windows track turns tightly and overshoot hardest, while longer windows behave more like a smooth trend line with the characteristic lead at inflections. A reasonable procedure is to match the window to the swing length you trade, then compare against an EMA of similar responsiveness to see which failure mode costs less.
Build LSMA your way.
Quant writes, tests, and refines it with you — then it runs on LuxAlgo charting or ports to TradingView.


