fxDreema

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

    sum of pass returns in loop, help?

    Questions & Answers
    2
    3
    161
    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.
    • A
      AxelForex last edited by

      Hi guys I've been stuck on this problem for a few days. I am trying to calculate volatility; the math is straight forward but several conditions of this math require me to run calculation through loops then averaging the result.

      For example, finding the price difference between day1's close and the day prior's close, I can run this calculation for each pass and with each pass the candles ID increases by +1, effectively moving back in time running this calculation for each pass/observation until the number of observations is met.

      This method was inspired to me by miro1360 on their post: https://fxdreema.com/forum/topic/4510/tutorial-loop-advanced-find-and-save-specific-value-from-indicator-history I see how Miro creates a system that can identify the highest and lowest value found thought the loop's return of ATR values, but what I need is to add the values from each pass and sum them so I can run a mean calculation.

      I can try to paint the picture of what I am trying to create:
      each pass advances one bar ID
      passValue1 + passValue2 +passValue3 + ... + passValue"n" = sum
      sum/"n" = average

      As far as I understand when I take the value of the first pass into a variable, it gets replaced by the return of the next pass thereafter and so on...

      I can't build a system that accumulates and sums the values of all passes ๐Ÿ˜ž

      The return of two closed daily price periods was just an example... I will be taking the mathematical process of summing and averaging variable return from each pass together, further once I figure out how to. ๐Ÿ˜‰

      Can anybody help me develop a process that is capable accumulating pass values.

      Thanks in advance for your time reading my post ๐Ÿ™‚

      1 Reply Last reply Reply Quote 0
      • jstap
        jstap last edited by

        Code works better for this, https://fxdreema.com/shared/9fq1qWdGb, I think this is what you want.

        Learn fxDreema Without the Wait!

        My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

        The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

        Donโ€™t miss out

        Click hereโžก๏ธ https://mybook.to/fxDreema to get your copy today!

        Enjoy! ๐Ÿ˜Š

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

          Yes this is the idea but I'm working on this for the purpose of the mathematical procedures it can calculate and a wide flexibility. So, what I'm looking for is not necessarily just the daily returns but more the accumulation of variable x which is different in every pass of a loop. Because I can use the built-in formula block to calculate the necessary math's but if I want to do this to find averages, I need to compute back in time by running the loop and adding the values.

          I will want to run larger calculations in the future and going into the custom code block and writing the mathematical code for each and every candle will be too extensive. I really appreciate your help in your suggestion I'll be keeping the code you wrote for when I need it in the future, but I'm still stuck on my initial problem.

          I've set the loop up so that on every pass a variable gets modified by +1, this I set as the candle id for every pass on 30 cycles. on the daily timeframe the loop computes through the last 30days and the math is calculated on every pass, I just need to sum the return of each pass.

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

          Online Users

          S
          J
          S
          C
          J
          E
          E
          S

          20
          Online

          146.7k
          Users

          22.4k
          Topics

          122.6k
          Posts

          Powered by NodeBB Forums | Contributors