English

## comparing all bars in a period to one another

 56 Dannoo007 2016.03.03 19:42   Hello forum.I am looking to set up this indicator where I want to add ALL differences among closing price - for ALL bars,  - compared to one another,  - within specified Period. How do you go about it?? I was thinking of a "Nested FOR" logic, but it wouldn't compile (see below).before I double check, will this ever work, at a conceptual level, or should this be done differently? simplified excerpt from OnCalculate() :`etc etc``//main cycle``int i,j,pos;``pos=Period-1;   ````for(i=pos; i
 66 jamescater 2016.03.03 20:23 #   Dannoo007: Hello forum.How do you go about it??before I double check, will this ever work, at a conceptual level, or should this be done differently? ```double sum = 0.0; int    Period = 10; int    pos = Period - 1;      for(int i = pos + 1; i < rates_total; i++) {    sum += close[i] - close[i-1]; } ```Although the loop is redundent because you are just summing the differences between the close prices. The problem can be reduced to the following```int    Period = 10; int    pos = Period - 1; double sum = close[pos] - close[rates_total-1];```