# Moving-average

## Moving-average :

Moving average is a technique used in technical analysis to smooth out short-term fluctuations in a data series and to highlight the underlying trend. It is calculated by taking the average of a certain number of past data points, typically over a specified period of time.
For example, let’s say we are analyzing the stock price of Company X over the last 10 days. To calculate the 10-day moving average, we would take the average of the closing prices for each of the last 10 days.
Suppose the closing prices for the last 10 days are:
Day 1: \$10
Day 2: \$11
Day 3: \$12
Day 4: \$13
Day 5: \$14
Day 6: \$13
Day 7: \$12
Day 8: \$11
Day 9: \$10
Day 10: \$9
The 10-day moving average would be calculated as follows:
(10 + 11 + 12 + 13 + 14 + 13 + 12 + 11 + 10 + 9) / 10 = \$11.50
Now let’s say a new day comes and the closing price for that day is \$8. We would then recalculate the moving average by dropping the oldest data point (Day 1) and adding the newest data point (Day 11):
(11 + 12 + 13 + 14 + 13 + 12 + 11 + 10 + 9 + 8) / 10 = \$11.00
As you can see, the moving average provides a smoother representation of the data series, as it filters out the short-term fluctuations and highlights the underlying trend.
Another example of using moving average is in forecasting future values. Let’s say we are analyzing the monthly sales data for a particular product over the last 6 months. The data looks like this:
Month 1: \$10,000
Month 2: \$12,000
Month 3: \$11,000
Month 4: \$13,000
Month 5: \$12,000
Month 6: \$11,000
To forecast the sales for the next month, we can use a 3-month moving average. We would calculate the moving average by taking the average of the last 3 months:
(12,000 + 11,000 + 13,000) / 3 = \$11,667
This tells us that we can expect the sales for the next month to be around \$11,667. However, this forecast may not be very accurate because it is based on only 3 data points. To improve the accuracy of the forecast, we can use a longer moving average, such as a 6-month moving average, which would take into account all 6 months of data.
In conclusion, moving average is a useful technique for smoothing out short-term fluctuations in a data series and highlighting the underlying trend. It can also be used in forecasting future values, although the accuracy of the forecast can be improved by using a longer moving average.