// iC3h.mq4 | by rockit
#property strict
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_minimum 0
#property indicator_maximum 13
double bufup[];
double bufdn[];
int up=0;
int dn=0;
int OnInit()
{
   string short_name="iC3h";
   IndicatorBuffers(2);
   IndicatorDigits(0);
   SetIndexStyle(0,DRAW_HISTOGRAM, EMPTY, 2);
   SetIndexStyle(1,DRAW_HISTOGRAM, EMPTY, 2);
   SetIndexBuffer(0,bufup);
   SetIndexBuffer(1,bufdn);
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
   return(INIT_SUCCEEDED);
}
int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) {
   int limit=rates_total-prev_calculated;
   if(limit>1) limit--;
   for(int i=limit-1; i>=0; i--)
   {
      int n=i+1;
   	double dir=close[n]-open[n];
      if(dir>0) {
      	up++; dn=0;
      }
      else if(dir<0) {
      	dn++; up=0;
      }
      bufup[n]=up; bufdn[n]=dn;
   }
   return(rates_total);
}
