Average value from a time period every day last 20 days

Forums ProRealTime English forum ProBuilder support Average value from a time period every day last 20 days

Viewing 10 posts - 1 through 10 (of 10 total)
  • #90615

    Hello!

    I am struggeling with an average movement between 09:00 and 09:30 (high – low). I want to sum the last 20 days and have an average. It seems easy but I really got stuck on this one. Simple example for 3 days below. I need this so there is a new average of 20 days looking back every day.

    day 1: High-low (between 09:00-09:30) = 30

    day 2: High-low (between 09:00-09:30) = 40

    day 3: High-low (between 09:00-09:30) = 20

    Average = 30

    #90619

    Store 20 variables and each day at 0930 move them all along one and then save the new values.

    Something like this:

     

    2 users thanked author for this post.
    #90622

    Or

     

    4 users thanked author for this post.
    #90636

    Thanks for that simpler version Roberto. Once again my brain avoided all possibilities of using SUMMATION. I don’t know why it does but it always does!

    1 user thanked author for this post.
    #90638

    I don’t think that the Roberto version will work correctly, as the summation will be made on the last 3 periods in real time, and in the last 3 bars, the day1 value is the same.

    1 user thanked author for this post.
    #90641

    Isn’t SUMMATION the sum of day[0] + day[1] + day[2] ?

    #90642

    Yes but in this case day[0] = day[1] = day[2], since you are updating the “day” variable once per day. It is a summation over 3 periods and not with 3 different data from the array.

    #90643

    Yes, Vonasi ‘s code is the correct one!

    Thank you Nicolas for pointing that out!

    1 user thanked author for this post.
    #90644

    Yes, Vonasi ‘s code is the correct one!

    Thank God for that! It means my brain is OK!

    #90673

    Thank you all for your help! Vonasis code worked perfectly.

    Have a nice day!

Viewing 10 posts - 1 through 10 (of 10 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login