Calculate Simple moving average and exponential moving average
-
Can some one explain how we calculate Simple moving average and Exponential moving average .
In more specific case if I want to calculate SMA at 9:15 AM on 19th March and on 9:30 AM on 19th march for 5 days , what is the formula Angel Broking is using for that -
@admin said in Calculate Simple moving average and exponential moving average:
talib
can you please share the talib library link?
-
HI @ameyakhot You can use the available library (talib ) which has 150 inbuilt indicators.
-
@admin @gurindersinghcs Can you share the code here as well? It'll be of much help.
-
@admin said in Calculate Simple moving average and exponential moving average:
I have shared the code file , please let me know what is wrong with the calculation
-
Hi @gurindersinghcs kindlymail us you piece of code @ api@angelbroking.com we will review the code and revert you back asap.
-
@admin said in Calculate Simple moving average and exponential moving average:
her option you have is
I have written a python file that is doing this calculation but some how the calculation does not match with the calculations I see on the Angel broking , I need to understand what is wrong with the way I am doing the calculation :
I will elaborate a little , I want to calculate last 5 days moving SMA
say for 19th March 9:15 AM and 19th March 9:30 AM
and I have closing rates for 18th , 17th , 16th , 15th and 12th March , to calculate SMA at 9:15 on 19th march I am adding (18th, 17th,16th and 15th along with closing of 19th 9:15) and dividing it by 5 and for 9:30 AM I am using (15th, 16th ,17th and 18th with closing of 9:30 AM on 19th ) and dividing it by 5.
can you please help were am I going wrong -
Hi@gurindersinghcs said in Calculate Simple moving average and exponential moving average:
Can some one explain how we calculate Simple moving average and Exponential moving average .
In more specific case if I want to calculate SMA at 9:15 AM on 19th March and on 9:30 AM on 19th march for 5 days , what is the formula Angel Broking is using for thatTo calculate sma ema etc you need to write the indicators code on your own or the another option you have is use external libraries.
-
@gurindersinghcs Moving average depends on the timeframe you are using it on. So if you are using 20 period MA on M15 chart then you should calculate MA based on the closing of the last 20 M15 candles. If you are using D chart then look for last 20 D candles. You can apply MA to OHLC of candle. It depends on your strategy. By default MAs are based on closing price.
-
Thanks @rjbanna for answering the question , can you provide some more details should I collect 15 minutes data for past 5 days and then use all of that in calculation or just the closing or opening of the day?
-
@gurindersinghcs You can use historical data of 15 minutes for the last 5 days and then calculate SMA and EMA based on OHLC.