In this article we are going to show a modified indicator for Metatrader 4 that allows to visualize a LSMA moving average (Least Square Moving Average) in any price chart of this trading platform.
This indicator was developed by experts of ForexDominion, is free to download and can be used by the trader at his or her own discretion.
Like any moving average, the LSMA can be used to follow the market trend and detect possible changes in price movements. However, unlike other moving averages like the SMA and EMA, its calculation method is more complex.
Basically, this indicator is based on the concept of linear regression, using the least squares formula to calculate each of the points on the LSMA line.
Next, we make a brief description of the LSMA moving average to understand how it can help the trader:
What is the LSMA moving average?
The Least Squares Moving Average (LSMA) calculates the least squares regression line for past time periods, leading to forward projections of the current period.
Consequently, the indicator has the ability to identify what could happen to the price if the regression line were to continue.
The indicator relies on the sum of least squares method to find a straight line that best fits the data for the selected period. The end point of the line is drawn and the process is repeated in each successive period.
The formula to calculate the line of best fit is:
Where n is the number of data points selected; x is the price; t is the date; a is the constant (the value when t equals zero); b is the slope of the line.
Thus, for the LSMA point, the indicator calculates the value using the following final formula:
LSMA = b * t + a
The Least Squares Moving Average is mainly used to identify bullish or bearish trends by price crossings with the indicator line.
Furthermore, it also generates signals when the price deviates from the indicator.
Now, like any other moving average, we need to assess when the LSMA indicates a change in trend.
If the signal changes to an uptrend along with the price recovery, a buy signal is generated. If the signal changes to a downtrend along with a price drop, a sell signal is generated.
LSMA Moving Average for MT4
As we already indicated, this modified indicator display a least square moving average on any instrument and time frame in Metatrader 4, as shown in the following image:
As you can see, this moving average follows price action quite closely, although, like any other moving average, it does not follow the price perfectly. It may also experience price lag (this lag increases as the number of periods used in the LSMA calculation increases) and can generate false signals.
In this case, we can modify both the number of calculation periods and the type of price used to calculate the LSMA, as we can see in the following image:
The only two configuration parameters are the following:
- LSMA Moving Average Period: Here we indicate the number of periods used in the calculation of the least squares moving average.
- Price applied in the calculation: The type of price used in the calculation of the indicator is indicated here. We can use the closing price, opening price, maximum price, minimum price, median price, weighted price and typical price.
Note: As we already indicated, this indicator is free to download. But if you want to use this and other known or little known types of moving averages like the SMA, EMA and adaptive moving averages, from a single indicator, you can get more information at: Magic MA Moving Averages MT4
Download and installation of the LSMA indicator for MT4
You can download this indicator at no cost at the following link:
You can access a complete list of free custom indicators for MT4 and MT5 in the following article: List of Custom Indicators For Metatrader
The Least Squares Moving Average is a little-known type of technical indicator that is calculated based on the least squares regression line for previous time periods.
In this sense, it tries to predict future price action with the linear regression method, providing signals that are different from those shown by other types of moving averages.
In this article we have presented a modified indicator for MT4 that allows to use that moving average in this trading platform. It is a simple indicator with few configuration parameters that can be downloaded free of charge.