array function get "array out of range"

 

Please help. Thanks!

            double BandU[];
            double BandL[];
            for (int i=1;i<5;i++)
            {

            BandU[i] = iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_UPPER,i);
            BandL[i] = iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_LOWER,i);
            }

I want to caculate standard dev of Bands upper and lower lines. Thnaks.

 
chnp:

Please help. Thanks!

I want to caculate standard dev of Bands upper and lower lines. Thnaks.

To make it kind of inverted :  what is the size of your BandU and BandL arrays? As soon as you answer that question, you shall have an answer to an array out of range question too

 
Mladen Rakic:

To make it kind of inverted :  what is the size of your BandU and BandL arrays? As soon as you answer that question, you shall have an answer to an array out of range question too

Thanks. I am a newbie. Do you mean using "ArrayResize"? I only need 4 numbers in the array. This still not working. Please help. Thanks!

            double BandU[];
            double BandL[];
            ArrayResize(BandU,4);
            ArrayResize(BandL,4);
            for (int i=1;i<5;i++)
            {

            BandU[i] = iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_UPPER,i);
            BandL[i] = iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_LOWER,i);
            }
            double stdbandsup = iStdDevOnArray(BandU,3,3,0,MODE_SMA,1);
            double stdbandslo = iStdDevOnArray(BandL,3,3,0,MODE_SMA,1);
            printf(stdbandsup+"   "+stdbandslo);
 
chnp: I am a newbie. Do you mean using "ArrayResize"? I only need 4 numbers in the array. This still not working. Please help. Thanks!
  1. Answer the previous question, and you would be half there.
  2. Of course it's still not working. What is the highest index you now store? Answer that question and you will know why.