//+------------------------------------------------------------------+
//|                                                     mn Egejo.mq4 |
//+------------------------------------------------------------------+
#property copyright "Mn"
#property link      ""

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue     
#property indicator_color2 Red

extern double mRngPcnt = 15;
extern int    mGap     = 15;

double UpBuffer1[], DnBuffer1[];
double mPipFact = 1;

//+------------------------------------------------------------------+
  int init()
  {
    if(Digits == 3 || Digits == 5)
      mPipFact = 10;

    SetIndexStyle(0, DRAW_ARROW);
    SetIndexArrow(0, 233);

    SetIndexStyle(1, DRAW_ARROW);
    SetIndexArrow(1, 234);  
    IndicatorBuffers(5);
    SetIndexBuffer(0, UpBuffer1);
    SetIndexBuffer(1, DnBuffer1);
    SetIndexLabel(0, "Dn");
    SetIndexLabel(1, "Up");

   return(0);
  }
  
//+------------------------------------------------------------------+
  int deinit()
  {
   
   return(0);
  }

//+------------------------------------------------------------------+
int start()
  {
   double mRng;
   static int mTime;
   int i, limit;

    int counted_bars = IndicatorCounted();
    if(counted_bars < 0)  return( -1 );
    if(counted_bars > 0)  counted_bars--;
    limit = Bars - counted_bars;
    i = limit - 1;

   for(i = limit; i >= 0; i--)
     {
      mRng = High[i+1] - Low[i+1];
      
      if(Time[i] > mTime && Close[i+1] > Low[i+1] + mRng * (100 - mRngPcnt) /100)
        {
         UpBuffer1[i+1] = High[i+1] + mGap * Point * mPipFact;
         DnBuffer1[i+1] = EMPTY_VALUE;  
         if(i < 2)
           Alert(Symbol(), "  ", Period(), " m  Up");
           mTime = Time[i];
        }
     
      if(Time[i] > mTime && Close[i+1] < Low[i+1] + mRng * mRngPcnt /100)
        {
         UpBuffer1[i+1] = EMPTY_VALUE;  
         DnBuffer1[i+1] = Low[i+1] - mGap * Point * mPipFact;
         if(i < 2)
           Alert(Symbol(), "  ", Period(), " m  Down");
         mTime = Time[i];
        }
     }
     
   return(0);
  }
  
//+------------------------------------------------------------------+