simple query about a for/next loop

Forums ProRealTime English forum ProBuilder support simple query about a for/next loop

Viewing 4 posts - 1 through 4 (of 4 total)
  • #55208

    Hi Nicolas, I have a simple query. for example: For i=0 to 10 do how do I write a code that adds up bars with close>open only (i.e. adds up green bars only)?    regards, Walid

    #55221

    If you want to use FOR…NEXT you may write:

    but there is a more elegant, fast and efficient way:

    Roberto

    #55238

    Hi Roberto,

    Thank you for your reply. Perhaps I was not clear enough in my query.

    BullCount = summation [11](close > open) will return the number of bars that meet the condition close > open in the last 11 bars. Let’s say for example it returned BullCount = 5 (i.e. there were 5 bars with close > open)

    What I am after is how I would then add the closes of these 5 bars together?

    Walid

    #55243

    This example multiplies CLOSE by the logical/boolean value 0 (when the condition is  false) or 1 (when true), so if there are 5 bullish bars their CLOSing price will be summed up.

    To adapt this to BEARish bars you just need to change the condition to “close < open”.

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

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