Firstly you must know when each group starts and ends, otherwise it’s impossible to determine.
Secondly, once you know that one group start, say 60 bars ago, and ends 35 bars ago, then you don’t need a FOR…NEXT loop, simply compute the difference between STRATEGYPROFIT[35] and STRATEGYPROFIT[60].
What are those numbers on the paper, 0…8, then 0 again (why again?)…3, and so on? Bars are numbered sequentially from 0 to the current one which ca be number 63856, there is no other bar identified by 0 than the very first one!
1 user thanked author for this post.