What Is a Moving Average?
Moving average (MA) is the average price of a security over a specific number of periods. Moving average smoothes out shortterm price fluctuations, giving technical analysts a clearer view of market trends (Figure 1).
Technical analysts often use a Simple Moving Average (SMA), in which each price level is equally weighted in calculating the calculation. Some technical analysts prefer to use an Exponential Moving Average (EMA), also known as an exponentially smoothed moving average, where the most recent price levels have the greatest weight, decreasing exponentially for older prices.
A Linearly Weighted Moving Average (LWMA) is another type of moving average similar to EMA, however, instead of exponential smoothing, LWMA assigns linearly decreasing weights to older prices.
Formula
Below is the calculation formula for the 03 types of moving averages mentioned above.
Simple Moving Average (SMA)
Where:

N: The number of periods used to calculate the average (the period length can be 1 minute, 5 minutes, 1 hour, 1 day, etc.)

SMA_{t}(N): Simple moving average at period t, calculated based on stock price of the most recent N periods;

P_{t}: Stock price at period t (can be closing price, opening price, high price, low price or average price of the period).
Exponential Moving Average (EMA)
Where:

EMA_{t}(N): exponential moving average at period t.
Linearly Weighted Moving Average (LWMA)
Where:

LWMA_{t}(N): linearly weighted moving average at period t, calculated based on the stock prices of the most recent N periods.
Example of Moving Average Calculation
Presented below are the calculation results for SMA, EMA and LWMA based on daily price data of FPT from 2/1/2024 to 15/1/2024, using the coefficient N = 5 days. The price used in calculation is the closing price of each day (unit: 1.000 VND).
The SMA calculation for 8/1/2024 and 9/1/2024 is calculated as follows:
The LWMA calculation for 8/1/2024 and 9/1/2024 is calculated as follows:
To calculate the EMA, it is important to determine the initial EMA value. Typically, this value is achieved by using the SMA formula:
After determining the initial EMA, the EMA for 9/1/2024 and 10/1/2024 is calculated as follows:
How to Use
Moving averages can be used in various ways. Firstly, whether the price is above or below the moving average is a signal for trend identification. In general, when the price crosses above the moving average, it indicates an uptrend in the stock. Conversely, when the price falls below the moving average, it suggests a downtrend in the stock.
Secondly, the distance between the moving average and price is also important information. After a downtrend, when the price returns to the moving average, this line can act as resistance level. Similarly, when the price begins to decrease after an uptrend, the moving average can act as a support level.
Additionally, two or more moving averages can be combined for enhanced analysis. The 5day moving average is often used as a shortterm momentum indicator, while the 20day or 60day moving average can be viewed as a longterm trend indicator. When the 5day moving average crosses above the longterm moving average can be used as a buy signal, and conversely, the 5day moving average crosses below the longterm moving average can be used as a sell signal.
In algorithmic trading both in Vietnam and globally, the moving average is the most commonly used technical indicator. All thirdparty softwares such as AmiBroker, TradingView or MetaTrader have integrated moving average indicators due to its simplicity of calculation as well as its application across various financial markets, owing to its reliance solely on price and volume data. Despite its status as a foundational concept in technical analysis, the profitability of this indicator has dwindled considerably.