filmov
tv
Simple Moving Average | Technical Indicators Strategies in Python | Quantra Course
Показать описание
Welcome to this video on simple moving average. After completing this video, you will be able to explain the moving average as well as the simple moving average, or the SMA. You will learn how weights are assigned to each data point while calculating SMA. You'll also be able to list the applications of the simple moving averages.
What is a moving average?
A moving average is also called a rolling average. It's simply the average of the specified data points over a selected period of time. For example, a 5-moving average represents the average of five data points. And a 10-moving average represents the average of ten data points.
This is the daily price data of stock A for the past 5 days. Can you guess the 5-moving average on the fifth day?
It would simply be the average of all the prices during the past 5 days. Now we have the price data for the past 6 days, what would be the 5-MA in this case?
As the new data for the 6th day has become available to us, we will drop the oldest value, that is, the price as on 1st Jan, and add the latest value, that is, the price as on 6th Jan. So, in essence, the mean or average is rolling along with the data, and hence the name moving average.
The reason for using a rolling window to compute the moving average is that unlike the regular average, which only considers stagnant data the moving average takes into account the most recently available data and replaces it with the most outdated data. This ensures that the analysis remains relevant in the current market scenario.
This is a line chart of 50 data points. This is how it looks when we plot a
5-moving average. To plot the moving average, we will calculate the average of the most recent five data points. All we need to do is take an average of the last five data points. So here the 5-moving average is 197.2. As we proceed to the next day we will drop the most outdated data and add the most recent data. We are dividing the sum of 5 data points by 5.
In other words, each data point has been assigned a weight of 1/5. We are giving a weightage of ⅕ i.e. 0.2 to all the data points. This means we are giving an equal weightage of 20% to all the data points while calculating the average. Hence, the sum of weights equals '1'. Since we are giving an equal weightage to every data point, it is called a simple moving average.
SMA can be easily plotted in all charting platforms, such as TradingView, without getting into the calculations. This is the price chart of the Apple stock from the period 5th May'22 to 30th Jun'22. To add the moving average indicator just click on the indicator tab and look for the moving average indicator. You can also customise it by changing the inputs.
Here let's take the 20-day simple moving average. This is how it looks once it's plotted. If you notice the original price chart, you can see that it has too many fluctuations. And so at any point, it's difficult to interpret the price trend. But if you see the moving average line, it's much smoother. It smoothens the price trend and makes it clearly visible and easier to interpret.
Here the SMA line is moving upwards, so this is an uptrend. Here it's moving downwards, so this is a downtrend.
Moving averages also act as a support and resistance point. For example, here the 20-SMA is plotted on a price chart. As you can see, the prices are trending upwards so the 20-SMA acts as a support. Similarly, on the second chart, the prices are trending downwards, so here the 20-SMA acted as a resistance.
Let's look for such instances on the Apple stock's price chart. We have set the lookback period for SMA as 20 days. This is a downtrend, and as you can see, the prices have not breached the 20-SMA line. So here the 20-SMA has acted as a resistance level. This is an uptrend, here the prices have touched the 20-SMA at multiple instances but have reversed right after.
But if you see this particular instance, you can see that the prices have breached the 20-SMA line. If you notice, you'll see that there is no particular trend here, the prices are more or less flat. So in such cases, where the prices are not trending, the SMA would not serve as an appropriate indicator.
To summarise what you've learnt, Moving Average represents the average of data points over a period of time. A simple moving average smoothens the prices and makes the trends clearly visible. It also acts as a dynamic support and resistance point.
That was all for this video.
Quantra is an online education portal that specializes in Algorithmic and Quantitative trading. Quantra offers various bite-sized, self-paced and interactive courses that are perfect for busy professionals, seeking implementable knowledge in this domain.