**lilses:**

Hi,

I made an indicator that shows signals based on volume; if the volume is higher than previous buy/sell as an example.

I run into out of range error with this code

int limit = MathMax(rates_total - prev_calculated,2);

for(int i=1;i<(limit);i++)

{

if (tick_volume[i]>tick_volume[i+1]) // **Out of range code points to this line**

{

//do code

}

//--- return value of prev_calculated for next call

return(rates_total);

}

When prev_calculated is 0, if i is limit-1 (last iteration), i+1 is equal to rates_total. Maximum index for tick_volume is rates_total-1.

Adjust your loop to avoid it.

Hi,

I made a very simple mt4 indicator that shows signals based on volume; if the volume is higher than previous buy/sell as an example.

I run into array out of range error with this code

int limit = MathMax(rates_total - prev_calculated,2);

for(int i=1;i<(limit);i++)

{

if (tick_volume[i]>tick_volume[i+1]) // **Out of range code points to this line**

{

//do code

}

//--- return value of prev_calculated for next call

return(rates_total);

}