help to make this code faster (array)

 

Hi,

I'm writing a EA for strategy tester purpose only, to evaluate portfolio. So I have hundreads/thousands of trades in an array, with open price and open time, and every 1 minute bar I check in a for loop if there's any trade to open in that minute. And it's taking forever.

How can I check (in a faster way) if in an array there's a open-time that coincides with current time?

Thanks!

   if(NewBar)
     {
      CopyRates(_Symbol,PERIOD_M1,0,5,candle);
      sizeAr=ArraySize(ar);
      arColumns=ArrayRange(ar,1);
      datetime candleNowTime = candle[0].time;
      datetime nextCandleTime = candle[0].time+60;      

      for(int i=0;i<sizeAr/arColumns;i++)
        {
         if(ar[i][openTime]>candleNowTime && ar[i][openTime]<nextCandleTime)
           {
            //code to open trades
           }
        }
     }
Razão: