Moving averages
Least Squares Moving Average on a Live Gold Chart
The least squares moving average fits the best straight line through the last 25 closes and plots where that line ends at the newest candle. A plain average describes the middle of the window; this one describes its end, which is why on gold it sits much closer to the latest candles.
What it shows
The LSMA appears as one line on the candles. It hugs price more tightly than a simple average of the same length and bends when the trend inside the window bends.
How Pravex works it out
- Take the last 25 values of the source price (the Length), the close by default.
- Fit a straight line through them by least squares, which is the line that makes the squared gaps between it and the closes as small as possible. Each candle counts as one step along the x axis.
- Read the line’s value at the newest candle. That value is the LSMA for this candle.
- Offset moves the reading point back along the same line by that many candles. A negative Offset reads further along the line, past the newest candle.
Settings
| Setting | Default | What changing it does |
|---|---|---|
| Length | 25 | How many candles the line is fitted through. A longer length gives a calmer line that hangs back more; a shorter one follows each swing. |
| Offset | 0 | Reads the fitted line that many candles before its end when positive, and further along past the newest candle when negative. This changes the value, not where the line is drawn. |
| Source | close | The price the straight line is fitted through. A wick-inclusive source like hlc3 makes the fit less sensitive to a single odd close at the end of the window. |
How traders read it
The slope of the LSMA is the quick read. A rising line says the closes in the window have been trending up, and a turn in its slope often comes before a simple average of the same length turns.
Price sitting well above the LSMA means the latest close is stretched over the fitted trend; well below, the reverse. That gap is a rough measure of how far the move has run inside the window.
When it misleads
A straight line fitted to a window only knows that window. When gold swings in a curve the end point swings with it, and one big candle at the end of the window can tilt the whole line and drag the plotted value. A negative Offset gives a value further along the same line, which is a projection of the old trend and not information about what comes next. Short lengths make it jumpy.
Questions and answers
What does least squares mean in the LSMA?
It is the fitting rule: the straight line is the one with the smallest total of squared gaps to the closes. Pravex fits a straight line through the last N closes by least squares and plots the line’s value at the newest candle, once per candle.
Why does the LSMA sit closer to price than a 25 SMA?
The SMA is the average level of the window, which lags half the window behind. The LSMA is where the fitted trend line ends, at the newest candle, so in a trend it stays near the latest price.
Is the LSMA the same as linear regression?
It is the end point of a linear regression line, one value per candle. The Linear Regression Channel draws the whole fitted line with bands around it; the LSMA joins up only the end points.
What does a negative offset do on the LSMA?
It reads the fitted line past the newest candle, an extension of the current window’s trend. That is a projection of the old slope, not a forecast, and it turns wrong the moment gold changes direction.
Related: Linear Regression Channel, Simple Moving Average, Hull Moving Average, Moving Average Exponential, every indicator.
Not financial advice. Read our disclaimer.
Pro charts. Zero paywalls.
Charts for gold, oil, US indices and crypto, with every tool free to use.
Open the chartNo card, no trial, no upgrade pop-ups.