 Hello everyone, welcome back to the session of moving average methods. Today in the previous session we have completed the simple moving average and weighted moving average and we have also illustrated them using Excel and now we will focus on exponential moving average and its application and its illustration using Excel too. So let us go to understand what is exponential moving average, why it has been used widely in the industry and how it has been calculated. So exponential moving average, the terminology itself it says that you know you will have the moving average like the way you have calculated the simple moving average or say weighted moving average, the concept will remain same but here or the moving average process will remain same but only thing is that maybe your cluster of or range of the data that you are taking in the cloud will also remain same, say 7 preord or 10 preords or say 4 preords, it will remain same. Only thing is that here in exponential moving average you assign some additional weight to the immediate pass data. So that additional weight assignments are being done through a formula, therefore we call it is a exponential moving average and that formula actually illustrated to the older data in a exponential manner. So it is smoothed out with the exponential way and there will be decay concept of the data or the weights to the older data, therefore we call it is exponential moving average, otherwise it is same like moving average process. So let us understand, look at here, since it gives some additional weight to the specific weight, there is a formula to the immediate data and rest of the weights are being distributed to the older data in your preord. So therefore there is a terminology called decay factor, you can see this decay factor. It is actually nothing but how you distribute your weight to the older data and solutionally it will be smoothed out through a you know exponential manner and then initial value whatever the weights you give we call it is exponential smoothing constant. So this constant you have to find and then you take a weighted average of immediate pass data and the rest data, the forecast data of that period and you drag the moving average. Let us see one illustration then we will get to know. Remember these points, this exponential moving average, moving average reacts faster to the new data compared to the simple moving average. So this is what most important part which is involved in exponential moving average that was not there in the weighted moving average or say in a simple moving average because in that case you take the simple weights and also weights you assign through optimization. But here what you do, you give a specific weight to the immediate period. So therefore you give special emphasis or special importance to the immediate period. In case you want to give more like you know you want to track the trend of the data, immediate trend of the data, in that case you know this exponential moving average actually work very well. So let us see how it works. So this is the formula of exponential moving average. First of all you have to select the weight, how much weight you want to assign or the smoothing constant you want to assign to the immediate period. Suppose you are at sixth period, so then to the fifth period how much weight you want to give, this alpha you have to find. There is a way of calculating that smoothing factor of the smoothing constant which will define the decay part of your exponential moving average, the remaining weights to the older data. So this way you can calculate it, I will tell you detail. So then first you assign then let us choose the time period that you want to select say 4 period or 7 period or 20 days moving average, whatever depending on your data and the problem and the statement and the context of the study. And then select the alpha value, accordingly you will get the alpha value automatically because if the number of period is 7, then N will become 7 here, if the number of period is 20, then N will become 20 here. So this way you can calculate your smoothing constant to the immediate period. So once you know that then you know calculate the initial moving average using the simple moving average. That means the initial value of to start with the exponential moving average you need some initial forecast. Like some initial value you have to assign, how will assign the initial like forecast value to a data that has been taken into account through simple moving average. And then once that initial step of assumption is done and you got a initial forecast value to a particular set or particular data, particular period and then you use your exponential moving average. And then you compute the process and drag the iteration and you will get the forecast for the forthcoming period. So here is the you know formula, exponential moving average formula is nothing but look at this is nothing but you know the actual data of previous period and the alpha constant that you are assigning plus weighted average, plus previous period exponential moving average into 1 minus alpha. So how does it work? Suppose I can give one illustration, we will get to suppose you have a data say like this type of data you have and suppose you want to consider say 4 period average. So 4th period exponential moving average, you want to consider. So in that case what you do 5th period you say because you have taken 4 period average plus 1 minus alpha into Y5 forecast. So how we will get that Y5 forecast? This Y5 forecast you have calculated by simple moving average for initial period. And then once you get the forecast for next period say Y6 period you got the forecast. So now you have a actual Y6 and the forecast of Y6 period. Now using this you can calculate the 7th period forecast. So you have actual say now for Y7 what will be the Y7 forecast? 7th period exponential moving formula you take alpha into Y6 plus 1 minus alpha of Y6 hat which you have already calculated. Now you are using this exponential weightage here, this formula you are using actually. So this way 1 by 1 you can drag your calculation and you may calculate your exponential moving average. Now how we will calculate alpha? Suppose if you have a say 20 days moving average, suppose if you take 20 days moving average in that case or 20 period moving average, so in that case your alpha will be 2 by 1 plus 20, some you know 9 percent or 10 percent weightage come over here. If you take say you know 10 days moving average in that case or 10 period moving average in that case your alpha will be 2 by 1 plus 10 around 18 percent it comes 18. something. So this way you have to initialize or you have to give initial value to the alpha that weightage to the immediate period because you want to give more importance to the immediate period and then you can carry forward. Even you can consider 200 days moving average also in stock market people is 200 days moving average. I will give illustration for that also at a later stage. So let us see this entire exponential moving average calculation process using a numerical illustration. So here you can see the illustration. So here suppose we have considered a 4 period average and we will use exponential moving average. But initially you know you have to start with your 5th period because 4 period average you have decided will fix it. The range is fixed now. Now what you do for 5th period you do not use exponential moving average because you do not have an initial data, you do not have the forecast for the 5th period. So you consider that forecast using simple moving average. Just take the average of this 4 period and you make the forecast for the 5th period. The error part you can write down that we will discuss later. Like the way we have done for weighted moving average, same we will be replicating here for this error calculation for the exponential moving average. That we already understood but we will discuss at a later stage. Now let us focus about the calculation process of exponential moving average. So here we found the forecast for period 5. So here it is Y5 actually. So forecast period we found using the simple moving average. Now once you get the forecast value for period 5, you have two points of reference. What is that? The actual of period 5, look at here. The actual value of period 5 and the forecast value of period 5. So Y5, actual value of Y5 and the forecast value. Now using this formula, look at the previous formula, previous slide, look at this formula. Using this formula, look at this formula you can forecast the forecast value of, you can get or calculate the forecast value of Y6. Look at my pen here. So forecast value of Y6 or simply this formula. So you go to the next and see how I have calculated the forecast for sixth period. So now sixth period forecast is nothing but, so previous period actual plus how much alpha 40 percent weightage I have given. Right? How come I found 40 percent here? I have taken the weightage, the alpha value is nothing but, you know, 2 by 1 plus 4 because 4 previous average I have taken. So this way I have calculated the weightages for immediate period. This is what the additional part in exponential moving average. The weightage or the smoothing constant or smoothing factor you have to initialize through this formula. And once you define it, it can be changed, the formula can be changed but generally people follow this logic of assigning exponential smoothing weights to that. Remaining 60 percent actually for this set of data you are distributing like you know for period 4 you can see the data here. For period 4 you 31 point for period 4 you are giving 40 percent weightages. For period 5 you are giving 40 percent weightages. Remaining 60 percent weightage you are giving to the forecast of period 5. That means, which from where you got it from the previous data sets. So effectively you are giving the remaining 60 percent to the older data. You have spread it and you might say that sir we are taking only period 5 actual and period 5 forecast. So therefore, we are just taking a weighted average of that period 5 only. No, you are actually taking into account of the previous data data points. How come? Because you have taken this period 5th forecast from the previous data and therefore, that in a iterative process that data are also been involved over there in Y5. So therefore, the 60 percent weightage that you are thinking about giving to Y5 forecast only actually you are spreading out to the older period. When I will drag the moving average you will get to know the concept in a better manner. Now, you got the forecast for 5th period using say simple moving average. Now, using this 5th period actual and 5th period forecast you can get using the exponential smoothing formula you may get the forecast for 6th period. I can show you how come it is. It will be 0.4 into 25 plus 1 minus 0.4 into 1 minus 0.4 into you know 27.5. This is nothing but the forecast for period 6 actually. So, now you got 6th period actual and 6th period forecast using that you can calculate the 7th period forecast. Similarly, suppose you want to calculate say 18th period forecast how will you get 17th period actual plus 17th period weightage of like 25 into say 0.4 plus 26.84 into 0.6. So, this way you can calculate the period for 18th. And you are actually following a moving average your dragging is actually but in a exponential smoothing with the help of exponential smoothing constant. So, this is what exponential moving average formula or moving average model and effectively you are dragging the moving average by considering the older data in a specific manner that is 40% weightage you are giving to the immediate past out of 4 periods. Immediate past period is getting suppose here you are calculating this 18th period say. So, you are giving weightage 100% weightage to this 4 but this 17th period are getting weightage of 40%. This is fixed remaining 60% you have distributed to the old calculation of exponential moving average the forecasted value you are actually integrating all the older data one by one and you are dragging it and effectively all this are being come here into the forecast of forecast value of 17th period. And once you get the 17th forecast and actually you have you can calculate the weighted average and you get the forecast for 18th period. These are the exponential moving average model. And now you can calculate the weight error part once you get the forecast value you can calculate the error part. So, this error you calculate and the absolute error you can calculate also like you know taking by taking the absolute value and then square of absolute value you can take. So, now you get the error if you take the absolute value of the error you will get you know the absolute value here and if you take the average you will get MAD. If you take absolute value by the actual value say 25 into 100 you will get the percentage error right and if you take the average of them you will get the mean percentage error. Now, if you take the square of the absolute value you will get the mean square error and then if you take the average of them I mean here 13 points are there I think 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13. So, if you take the average of the square of the error you will get the mean square error and if you take the square root of it you will get the RMSC. So, this is what the exponential moving average and you want to see the graph of it you can see the graph of them also. So, here also like weighted moving average or simple moving average you have also taken 4 period average to start with the beginning point with 45th period forecast. But here you have given you know some additional weight specific weight to the immediate period how much weight you have given 40 percent that is fixed. So, that means you know 2 by 1 plus 4. So, this weightage you have given to the immediate period and then this is what your alpha and then you drag this. So, when you are forecasting this next period say 6th period you are giving 40 percent weightage to this period you are dropping the older period and you are considering this 4 period this 4 period and you are making forecast for the next period and that actual and you can write down the error and error here that we have discussed in the previous slides. So, this way you can make the forecast for the forthcoming period and this process are called you know exponential moving average model. This is very popular in the you know financial sector especially in the stock market analysis because they want to see the movement of the stock price and they want to do a swing trading over here there. So, in that case they actually see how they actually gives the importance to the immediate period how the last 1 hour or 2 hours or last 20 minutes what happened or last 5 minutes what happened. So, this way they break the time periods and they actually use the formula and they calculate even for the longer periods say for 10 days, 20 days also you know 200 days also they follow 50 days also they follow this exponential moving average because they feel this is better than the simple moving average because they give importance to the immediate period. For example, imagine if you have a 200 days moving average if you consider your cluster of 200 days. So, you need good amount of data huge amount of data you require and then you drag your moving average and in that case if you take 200 days moving average your alpha value will be 2 by 2 by you know 1 plus 200. So, around 1 percent weightage will come however less than 1 percent probably. So, this much weightage we are giving to the immediate period rest of the period out of your 200 days club rest of the periods will assume some weights, but that will be distributed exponentially. Therefore, we call it as exponential moving average method. Now, we will illustrate this exponential moving average using Excel. So, let us go to the Excel and understand this calculation process. So, here I have opened the Excel sheet you can see here same data sets I have taken and for period average I will be considering. So, here you can see 0.4. So, how come I got 0.4? Look at here the formula look at here. So, 2 by 1 plus 4. So, it is coming out to be 40 percent weight right and this will fix and now we will drag the moving average. But for 5th period as I mentioned for 5th period you do not have the moving exponential moving average formula. So, you take the initial assumption of simple moving average. So, here we have taken the simple moving average to start with the initial data for 5th period. So, that 6th period onwards you can actually use the exponential moving average formula. Now, this is the forecast simple average I have taken for 5th period. This is the forecast and this is the error you can see and the square error is written here in the right hand side and MSE I have calculated. So, look at the square error. So, that part different we will discuss later. Now, you see the formula. Now, once you get 5th period actual and 5th period forecast using the formula that I have shown you like you know let me write it here again using the formula. So, alpha into actual say plus 1 minus alpha into say forecast right. So, this formula we are using now. So, 5th period you suppose here let me write down this way also. So, you will get a better clarity. So, you will get the forecast for the 6th period. So, now this look at here. So, for 6th period how we will calculate this look at this alpha of 5th period actual alpha is how much the exponential constant the smoothing constant is 40 percent alpha of actual plus 1 minus alpha say 60 percent of the forecast. So, this forecast you got the from the previous data. Now, you drag it once you drag it for 7th period 8th period you are considering the previous period, but actually you are distributing the weight 40 percent of the immediate rest 60 percent to the older right. And once you smooth it out actually you are actually you are considering this exponential average where the decay function are coming and 40 percent weightage to the immediate rate rest 40 percent you have distributed to the older period which will give you a combination of the forecast to the to that period through exponential moving average that is it. So, now you do it now if you drag this now 6th period calculation you have done for 7th period same way 6th period data and forecast you found now exponential smoothing average moving average is actually working. Now you have got the calculation and the forecast you drag it I can show you the let us drag it. So, you got the forecast for all the periods now. So, here you want to see the 18th period forecast look at 17th period actual let me put a color 17th period actual and 17th period forecast you found using the from moving average formula and using them you calculate your forecast for the 18th period that is it and you found the forecast. So, this forecast is the forecast for the 18th period right hold it. Now, we have calculate the error here look at the error suppose here you can see say error say here actual minus forecast this we have calculated all the error and the square part we have taken I have calculated only the mean square error in this sheet, but if you see in the previous session we have discussed detail of calculation right for MAD, MAP and MSE etcetera and we have found the calculate intercalculation for simple moving average and for weighted moving average. We have done that for name method also in some session. So, now we are concentrating only the MSE and the RMSE value. So, we will calculate the MSE now the average of all the error here you can see the sum of the error and then average of all the error look at this total by total error square and sum and then by 13th and then we found the RMSE which is the square root of this. So, you found the RMSE and you got the forecast also and how much is the RMSE 1.98 remember it using this formula we have used the calculation of alpha and the corresponding forecast through exponential moving average and forecast is 26.10 that is not a objective I already told you that what forecast value we are getting through a particular time series formula or moving average formula that is not the main part, main part is the RMSE value what is the error or MSE value or the measure of accuracy. So, now let us see these three calculation process or you know in a summary in our PPT. So, that means we have calculated the simple moving average we have calculated the exponential moving average we have calculated the forecast of you know exponential moving average and weighted moving average. Now, we have got the RMSE for all of them and the corresponding forecast of them. So, I now we will compare all three and put in a single graph. So, let us see and look at the final summary here. So, if you see here we have done the comparison of all the three models of moving average. So, simple moving average for the same data sets right. So, MAD you found this and simple moving average and for weighted moving average and for exponential moving average at these values. Now, if you see the MAP mean absolute percentage error which model is for the same data which model is giving the least error percentage error weighted moving average. So, we can say that weighted moving average is better. Even RMSE if you check RMSE look at weighted moving average is giving the least error. So, higher accuracy least error means higher accuracy. So, therefore, we can conclude that for this particular data sets that we have used and we have tested all three model and weighted moving average is best. But everybody has a merit simple moving average takes simple average only if the data are steady it is fine. But weighted moving average gives the data understand the data pattern and gives some additional weightage to the particular period and how to optimize the weight to the different periods that also we have discussed using optimization solver you can find the weightages for all the period. That means, even if you take a 7 days moving average you get the 7 weightage right for all the days all the periods. So, that also weights you can also calculate for using the excel solver. So, that means for all 7 period the W1 to W2 up to W7 the all weightage will be finalized using the data and you can optimize it. So, once you finalize that you drag it you will get the forecast for weighted moving average. Now, for exponential moving average you do not have to optimize the weights because it is been assigned how much to the initial to the immediate past period because if you want to see the trend of the movement of the data quickly. So, in that case exponential moving average is very good and in that case you give weightage like alpha 2 by 1 plus n. So, this formula you assign to the immediate period rest of the weight you distribute to that all that period of your moving average process and this is what exponential moving average and all three method we have discussed and here is the summary. For this particular data exponential moving average may not be better and weighted moving average is coming to be the best, but for different data especially the stock price analysis etcetera exponential moving average gives a better accuracy and if people actually follow exponential moving average than the weighted moving average. So, we understood all the three model now and here you can see the graph and to some extent for this particular data all are giving good predictions, but you may not be able to understand which graph is best, but in terms of error and the forecast accuracy we can conclude that weighted moving average is better for this particular data sets. So, this is what the three models of you know moving average methods there are many more methods which you can understand you can learn, but for the time being we understood these three methods which have been popular and been used in the industry. Now, one part out to you know discuss with you that why exponential moving average is so popular in the stock market because if you go to you know money control or if you go to you know screener or if you go to any new channels of you know the stock market say you know CNBC or say you know ET etcetera. So, you will get to know or even G business you will see that most of the experts will talk about moving average, exponential moving average they do not use the word exponential moving average, but they actually use this calculation which I have shown you today the exponential moving average, but they use the all of DMA like DMA. So, how many like you know to 7 days DMA, DMA, 20 days DMA, 50 days DMA, 200 days DMA what does it mean? It means that they are taking the stock price say you have a data and they are taking say 200 days average for long term predictions for long term investor 200 days moving average are good, but for 50 days moving average are good, but for short term predictor or say investor you know trader 7 days, 20 days moving average is good even short period like to say 7 minutes small period you can consider and you can take the average and you can take the exponential average and you can carry forward the forecast. For example, here you can see I will I will show you one example here if you see here how the technically this models are so popular and why people follow it you will get to know. I will show you one example how high in stock market people use this particular exponential moving average method for their analysis. So, technically how you can read it? Let us see suppose you have a data say stock price is moving like this say stock price is moving suppose like this suppose right and suppose if you see let me put a different color and if you see say 200 days moving average suppose 200 days I am talking about for long term investors suppose 200 days moving average are coming out to be suppose like this suppose like this. So, in that case this is your 200 days moving average this one and this is your stock price right the red one. So, in that case what happens you can see that over a period of time you see that your stock price is trading above your 200 days moving average that is it is in over what zone. So, do not buy now you wait for correction there may be high chance that it may go down stock price may go down. But now you know in case suppose if you take another case suppose you know in case your stock price are say suppose you know are like this trading like this and your 200 days moving average say are here. So, in that case what happens your stock price is trading below the 200 days moving average this is your 200 days moving average look at here. So, your stock price is trading below 200 days moving average there is a high chance that it may bounce back if the you know fundamental of the stock is good management is good there is a high chance the stock price may go up because last 200 days average says that it is oversold it is in oversold zone. That means, there is a less chance it can have it may go down further, but there is a less chance that it may go down further there is a high chance that it may go up. So, you invest here in this zone invest because it is trading near 200 days average below average 200 days below average. So, this is what you know people use the technical chart people read the technical chart through 200 days moving average or 50 days moving average and you get a forecast and accordingly you can see the accordingly you can trade or you can invest you can buy the shares and sell the shares. So, now if you look at here look at this graph I have taken from a source. So, you know look at this graph the blue graph is a 20 days exponential moving average say 20 days only for short term prediction you can think about for trader or 3 months trader etc. You can buy sale etc this type of recommendation can be done through this graph. Let us see how you can make a recommendation or you can get a better insights about stock price analysis through this exponential moving average. Now, suppose if you see the stock price look at the movement of the stock price it is been mentioned here in the graph and look at the 20 days exponential moving average. So, if you see here look at here stock price is trading here right look at here. So, your 20 days average is below the stock price. So, stock price is over abroad zone. So, do not buy here and there is a there might be chance that there will be a correction. So, better to wait for correction and then you buy look at here here here it is below it is trading below 200 days moving average 20 days moving average. So, you buy here buy here buy here there is a high chance that it may bounce back look at how it is bounce back. If you look at this case stock price is quite high it is in over abroad zone. So, do not buy here wait for corrections otherwise you will get stuck for couple of months or couple of years that could happen also. Suppose do not buy here rather you wait for correction because 20 days average is below that you know trading price now. So, you wait for corrections and when it go down you buy it it could be a high chance that it may bounce back and you will be in profit. Look at from here if you buy here and your stock price comes here look at the bounce back. So, you will get a huge amount of profit actually. So, therefore, you wait for corrections and whenever if you see the graph of say 200 days or 20 days or 50 days moving average or DMA and it is which trading below that or nearby that you better to buy that time. And if it is trading above that you know moving average line. So, you wait and there will be high chance that there will be profit booking because traders make profit booking investor might not do that, but trader will do that and trader will bring it down the stock price and you can get the opportunity to buy it lower price. So, you buy that. So, therefore, you know this exponential moving average or DMA people call it in the technical analysis talking as you know DMA, but this exponential moving average is very popular in stock market and I thought of giving one example for that as application. But overall you know this is a method you can use in other application area also it is not that only in you know financial sector you can use it as a merit. Only thing is that for the immediate period when there is a trend in the data you have to capture the trend or the swing of the data. In that case, you better to follow exponential moving average than the simple moving average or weighted moving average because here you give some additional importance to the immediate data and that has been also been fixed like 2 by 1 plus n. So, this way you can you know understand the exponential moving average, but in the previous session of today we have discussed the simple moving average and the weighted moving average also. Now, you can conclude that the three methods of moving average process or moving average methods of time series one is the simple moving average and that the weighted moving average and the third one is the exponential moving average. We have also illustrated in Excel I hope you understood the three methods and we can wind up the today's session of moving average and we can carry for the discussion to the exponential series of time series methods in the forthcoming session. Thank you.