fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    Calculating Simple Moving Average of a Indicator

    Questions & Answers
    2
    3
    1983
    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.
    • R
      rafaelgrecco last edited by

      Hi! I am trying to calculate the SMA (simple moving average) of a Indicator.

      Simple Moving Average is the sum of the closing prices divided by the period number.

      Example SMA for 5 periods: (1.0399 + 1.0394 + 1.0387+ 1.09375 + 1.09382) / 5 = 1.0387

      This is calculated automaticaly by the indicator.

      I want to have a Simple Moving Avarage for a Indicator, for example Momentum. The calculus would be same same, but using Momentum data instead of price, so I can compare them.

      Example SMA for 5 periods of Momentum Indicator: (100.2094 + 99.9420 + 99.0634 + 99.2944 + 99.4350) / 5 = 99.8884 - This would be the SMA that I wanted.

      This way I can compare the SMA of the Indicator with the Indicator data itself.

      What I currently have is:

      Have 5 Variables (M1 to M5), each with a Candle ID (0, 1, 2, 3, 4) of the Momentum Indicator. Then use Formulas blocks to sum all variables and put on secondary variables so I can sum all of them:

      M1 + M2 = T1
      M3 + T1 = T2
      M4 + T2 = T3
      M5 + T3 = T4 (here I have all candles summed up)

      Now divide T4 by 5 = SMA. This is the Simple Moving Average of the Indicator.

      Now imagine I want a SMA of 9, 14 or 21 periods... it would be too much to do this way. Is there a better and simpler way to achieve this?

      Thanks.

      1 Reply Last reply Reply Quote 1
      • R
        rafaelgrecco last edited by

        Ok, I figured it out.

        Each "Modify Variables" can modify up to 5 variables at once, so 3 blocks can handle 14 periods for example.

        The "Formula" block only has simple operations, but we can add more operations on "Adjust the result" field. So we can sum all variables (as many as we want) using a single block.

        It is a lot of stuff to keep track, but it works using only a few blocks. I should have tested a little more before posting.

        Anyway, I hope this information can help someone if they are looking to do something similar.

        1 Reply Last reply Reply Quote 2
        • P
          ptejerina last edited by

          Hi,

          I programmed a custom indicator that shows the moving average of ATR. This may help you or others to achieve something similar.0_1496012111333_ma_atr.mq4

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

          Online Users

          T
          S
          A
          M
          M
          E
          C
          M
          F
          L
          F
          F
          E
          K

          29
          Online

          146.6k
          Users

          22.4k
          Topics

          122.6k
          Posts

          Powered by NodeBB Forums | Contributors