Last six candles types

 
Hello everyone. Is there a way of calculating how many of the last six candles were bearish or bullish? I 've tried but I keep getting the array out of range error. 
 

Code:

//+------------------------------------------------------------------+
//|                                                            2.mq5 |
//|                              Copyright © 2019, Vladimir Karputov |
//|                                           http://wmua.ru/slesar/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2019, Vladimir Karputov"
#property link      "http://wmua.ru/slesar/"
#property version   "1.001"
//---
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   MqlRates rates[];
   ArraySetAsSeries(rates,true);
   int start_pos=0,count=6;
   if(CopyRates(Symbol(),Period(),start_pos,count,rates)!=count)
      return;

   int count_bullish=0, count_bearish =0;
   for(int i=0; i<count; i++)
     {
      if(rates[i].open<rates[i].close)
         count_bullish++;
      else
         count_bearish++;
     }

   Comment("bullish: ",IntegerToString(count_bullish),"\n",
           "bearish: ",IntegerToString(count_bearish));
  }
//+------------------------------------------------------------------+

Result:


Files:
2.mq5  4 kb
 
Vladimir Karputov:

Code:

Result:


Thank you so very much! You are a life saver