Your indicator loop is decrementing ?
If Indicator loop i starts at the highest bar index what is i + 1 ? Bar does not exist.
When indicator gets down to calculating zero bar i what is i - 1 ? Bar does not exist.
Logic goes like this,
The highest available Bar is Bars-1.
If buffer1[i] begins from Bars-1 and you want buffer2 to call buffer1[i+1] all through the chart, then buffer2[i] should begin from Bars-2
If you want buffer2[i] to call Buffer1[i-1] you can only do that when buffer2[i] > 0 unless you make buffer1 calculate a value for Bar -1.
int counted = IndicatorCounted();
// if(counted < LB0) counted = LB0; // Do you look at earlier values for buf_0?
for(int iBuf0 = Bars - 1 - counted; iBuf0 >= 0; iBuf0--)
buf_0[iBuf0] = ...
#define LB1 1
if(counted < LB1) counted = LB1; // You DO look at earlier values for buf_1
for(int iBuf1 = Bars - 1 - counted; iBuf1 >= 0; iBuf1--)
buf_1[iBuf1] = ... buf_0[iBuf1+LB1] ... // Look back 1
To add comments, please log in or register