//-----------------------------------------------------------------------------
//                                                 Mn ConsecHL                |
//-----------------------------------------------------------------------------

#property copyright "MP"
#property link      ""

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DarkGreen  
#property indicator_color2 DarkRed
#property indicator_width1  0
#property indicator_width2  0

extern int mHist = 999999, mVal = 2;
extern double mGap = 0;
double mHigh[], mLow[];
int mHighCount = 0, mLowCount = 0;

//-----------------------------------------------------------------------------
void init() {
  SetIndexBuffer(0, mHigh);
  SetIndexBuffer(1, mLow);
  
  SetIndexEmptyValue(0, 0);
  SetIndexEmptyValue(0, 0);
  
  SetIndexStyle(0, DRAW_ARROW);
  SetIndexArrow(0, 108);

  SetIndexStyle(1, DRAW_ARROW);
  SetIndexArrow(1, 108);  
  
  if(Digits == 3 || Digits ==5)
    mGap = mGap * Point * 10;
  else
    mGap = mGap * Point;
}

//-----------------------------------------------------------------------------
void start() 
{
    
  for (int i = mHist; i >= 1; i--) 
  {
    if(Close[i] < Close[i+1]) 
      {
       mHighCount++;
       if(mHighCount == mVal)
        mLow[i] = Low[i] - mGap;
      }
    else
      mHighCount = 0;

    if(Close[i] > Close[i+1]) 
      {
       mLowCount++;
       if(mLowCount == mVal)
        mHigh[i] = High[i] + mGap;
      }
    else
      mLowCount = 0;
      
  }

  return(0);
}

//-----------------------------------------------------------------------------
void deinit()
 {

 }

//-----------------------------------------------------------------------------

