Array out of range

To add comments, please log in or register
Bartlomiej Winter
107
Bartlomiej Winter  

Hi all,

I get the array out of range error and I cant seem to figure out why! Any help is greatly appreciated!


   MqlRates PriceInfo[];
//Sorts it from the current candle to the oldest candle
   ArraySetAsSeries(PriceInfo,true);
//Copies the price information into the array
   double Data=CopyRates(Symbol(),PERIOD_CURRENT,0,Bars(Symbol(),PERIOD_CURRENT),PriceInfo); //THIS SHOULD HAVE PERIOD_D1

   Bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);
   
   Comment(StringFormat("Current price  = %G\n",Bid));
   
   double high_price[]; //Store the high price
   double low_price[]; //Store the low price
   double close_price[]; //Store the close price
   ArrayResize(high_price,no_candles+1);
   ArrayResize(low_price,no_candles+1);
   ArrayResize(close_price,no_candles+1);

   for(int i=0; i<=no_candles; i=i+1)
     {
      high_price[i]=PriceInfo[i+1].high;
      low_price[i]=PriceInfo[i+1].low;
      close_price[i]=PriceInfo[i+1].close;
     }
nowayfra
29
nowayfra  
You are sure that (no_candles + 1) < Bars(Symbol())? Otherwise it exceeds the range of PriceInfo[].
To add comments, please log in or register