//+------------------------------------------------------------------+
//|                                                        IB.mq4 |
//+------------------------------------------------------------------+

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Lime
#property indicator_width1 4
#property indicator_width2 4



//---- buffers
double val1[];
double val2[];
datetime prevtime = 0;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {

//---- indicator line
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_HISTOGRAM,0,3);
   SetIndexStyle(1,DRAW_HISTOGRAM,0,3);
   SetIndexBuffer(0,val1);
   SetIndexBuffer(1,val2);

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    CB=IndicatorCounted(); if (CB==0) CB=2;
   if (prevtime == Time[0]) return(0);
   prevtime = Time[0];
     
   for (int i = 1; i <= Bars - CB; i++) {
      
      if ((High[i+1]>=High[i] && Low[i+1]<Low[i]) || (High[i+1]>High[i] && Low[i+1]<=Low[i])){
		    val1[i]=High[i]; val2[i]=Low[i];
		}       
   }
   return(0);
  }
//+------------------------------------------------------------------+