Skip to content

Indicator Formula

Technical Details — Least Squares Moving Average (LSMA)

Section titled “Technical Details — Least Squares Moving Average (LSMA)”

The Least Squares Moving Average (LSMA) fits a linear regression line to the last n prices and uses the end point as its value. This approach projects the trend forward, making LSMA one of the most responsive moving averages.


Mathematical Derivation

Purpose: Find the best-fit line through the last n prices.

$$y = a + b \times x$$ $$b = \frac{n\sum xy - \sum x \sum y}{n\sum x^2 - (\sum x)^2}$$ $$a = \frac{\sum y - b \sum x}{n}$$

Where:

  • $$x$$ = Bar index (1 to n)
  • $$y$$ = Closing prices
  • $$b$$ = Slope
  • $$a$$ = Intercept

What This Measures: The best-fit line through recent price history


Purpose: Use the regression line’s endpoint as the LSMA value.

$$LSMA[t] = a + b \times n$$

What This Measures: The projected end of the regression line — the trend-adjusted average



Compact Formula Summary

$$b = \frac{n\sum xy - \sum x \sum y}{n\sum x^2 - (\sum x)^2}$$ $$a = \frac{\sum y - b \sum x}{n}$$ $$LSMA[t] = a + b \times n$$

Default Parameter: Period (n) = 14


Complete Calculation Example

LSMA fits a regression line to prices. If the trend is upward (positive slope), LSMA’s endpoint projects ahead of the average — capturing direction better than standard MAs.


Key Takeaways from the Example
  1. Regression-Based: Uses statistical line fitting rather than simple averaging
  2. Trend Projection: The endpoint naturally captures trend direction and speed
  3. Very Responsive: Reacts quickly to trend changes because the slope adjusts immediately
  4. Can Lead Price: In strong trends, LSMA projects ahead, appearing to predict price movement