Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    Calculate Simple moving average and exponential moving average

    General Discussion
    4
    11
    114
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      gurindersinghcs last edited by

      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

      J 1 Reply Last reply Reply Quote 0
      • J
        jiwan1986 @gurindersinghcs last edited by

        @gurindersinghcs You can use historical data of 15 minutes for the last 5 days and then calculate SMA and EMA based on OHLC.

        G 1 Reply Last reply Reply Quote 0
        • G
          gurindersinghcs @jiwan1986 last edited by

          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?

          J 1 Reply Last reply Reply Quote 0
          • J
            jiwan1986 @gurindersinghcs last edited by

            @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.

            1 Reply Last reply Reply Quote 0
            • A
              admin last edited by

              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 that

              To calculate sma ema etc you need to write the indicators code on your own or the another option you have is use external libraries.

              G 1 Reply Last reply Reply Quote 0
              • G
                gurindersinghcs @admin last edited by

                @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

                A 1 Reply Last reply Reply Quote 0
                • A
                  admin @gurindersinghcs last edited by

                  Hi @gurindersinghcs kindlymail us you piece of code @ api@angelbroking.com we will review the code and revert you back asap.

                  G 1 Reply Last reply Reply Quote 0
                  • G
                    gurindersinghcs @admin last edited by

                    @admin said in Calculate Simple moving average and exponential moving average:

                    api@angelbroking.com

                    I have shared the code file , please let me know what is wrong with the calculation

                    A 1 Reply Last reply Reply Quote 0
                    • A
                      ameyakhot @gurindersinghcs last edited by

                      @admin @gurindersinghcs Can you share the code here as well? It'll be of much help.

                      A 1 Reply Last reply Reply Quote 0
                      • A
                        admin @ameyakhot last edited by

                        HI @ameyakhot You can use the available library (talib ) which has 150 inbuilt indicators.

                        S 1 Reply Last reply Reply Quote 0
                        • S
                          sevrus @admin last edited by

                          @admin said in Calculate Simple moving average and exponential moving average:

                          talib

                          can you please share the talib library link?

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post