# What is Moving Average Formula

Updated: Apr 29

## What is Moving Average Formula

Here are the formulas for the three most common types of moving averages:

### Simple Moving Average (SMA):

SMA = (Sum of Data Points in Moving Period) / (Number of Data Points in Moving Period)

For example, to calculate a 5-day SMA of stock prices, you would add up the closing prices for the past 5 days and divide the total by 5.

### Weighted Moving Average (WMA):

WMA = [(P1 x w1) + (P2 x w2) + ... + (Pn x wn)] / (w1 + w2 + ... + wn)

Where:

P1, P2, ..., Pn are the data points

w1, w2, ..., wn are the corresponding weights for each data point

For example, to calculate a 5-day WMA with weights of 1, 2, 3, 4, and 5, you would multiply each data point by its weight, add up the results, and divide the total by the sum of the weights (1+2+3+4+5=15).

### Exponential Moving Average (EMA):

EMA today = (Price today x Smoothing factor) + (EMA yesterday x (1 - Smoothing factor))

Where:

Price today is the most recent price

EMA yesterday is the EMA value from the previous day

Smoothing factor is a value between 0 and 1 that determines the rate at which the weights decrease

For example, to calculate a 5-day EMA with a smoothing factor of 0.33, you would use the most recent price as the starting point and then use the formula above to calculate the EMA for each subsequent day.

## What is Moving Average

__Moving average__ is a statistical technique used to analyze time-series data. It helps to smooth out fluctuations in the data and identify trends by calculating the average of a specific number of data points within a given time period.

For example, if we have daily closing stock prices for the past 5 days, we can calculate a 5-day moving average by adding the closing prices for each day and then dividing the total by 5. This gives us an average price over the past 5 days, which can help to identify trends and reduce the impact of short-term fluctuations in the stock price.

There are different types of __moving averages__, such as simple moving average, weighted moving average, and exponential moving average. Each type has its own strengths and weaknesses, and the choice of which one to use depends on the specific context and goals of the analysis.

Overall, moving average is a useful tool for analyzing time-series data and gaining insights into trends and patterns over time.

Learn More : ** Exponential Moving Average(EMA) Calculation with Python** |

**|**

__What is Exponential Moving Average(EMA)__

__Mastering Moving Averages: A Guide to Analyzing Time-Series Data and Identifying Trends__