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
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?
BullSum=summation[11](close(close>open))//sum of CLOSing price of last BULLish bars
BullSum=summation[11](range*(close>open))//sum of RANGE of last BULLish bars
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”.
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue