Need Help to resolve "Array out of range"

 

I don't have this error previously but suddenly this "Array out of range" appear when I tried to execute the EA. Somehow, it's not giving any error during compiling in MetaEditor so far.

Thanks.

for (int a = 0; a < ArraySize(Pairs); a++)
    {
        string     CurrentPair = Pairs[a];
        double Ask_Price       = MarketInfo(CurrentPair, MODE_ASK);
        double Bid_Price       = MarketInfo(CurrentPair, MODE_BID);
        int        opentrades  = OpenTrades(CurrentPair);
        // log("Current Pair: ",Pairs[a]);
        Adr = ADR[a];
        //global to hold the index of the pair in the pairs array
        PairIndex = a;

        int spread = MarketInfo(CurrentPair, MODE_SPREAD);

        if (CurrentPair == Pairs[ThisSymbolIndex])
        {
            //log("Processing Active chart Pair", CurrentPair);
            if (Adr == 0.0)
            {
                return(0);
            }
        }
 
parksonchew: I don't have this error previously but suddenly this "Array out of range" appear when I tried to execute the EA. Somehow, it's not giving any error during compiling in MetaEditor so far.
  1. It didn't suddenly appear, either you previously had it and didn't notice, or changed something that caused it.
  2. Array out of range has nothing to do with compile errors. It's a run time error.
  3. How can we possibly help when you don't show all the relevant code? Your a loops on the array Pairs, but you also use it to index into ADR which you don't show. You also index into Pairs using ThisSymbolIndex which you also don't show.
  4. Add print statements and track it down. At least size of Pairs, size of ADR, value of ThisSymbolIndex.