//+------------------------------------------------------------------+
//|                                           Daily Range PeterE.mq4 |
//+------------------------------------------------------------------+

#property indicator_chart_window

extern int      NumOfDays             = 10;
extern string   FontName              = "Courier New";
extern int      FontSize              = 10;
extern color    FontColor             = White;
extern int      Window                = 0;
extern int      Corner                = 2;
extern int      HorizPos              = 5;
extern int      VertPos               = 20;

double pnt;
int    dig;
string objname = "*DRPE";

//+------------------------------------------------------------------+
int init()
  {
//+------------------------------------------------------------------+
   pnt = MarketInfo(Symbol(),MODE_POINT);
   dig = MarketInfo(Symbol(),MODE_DIGITS);
   if(dig == 3 || dig == 5)
     {
      pnt *= 10;
     }
   ObjectCreate(objname,OBJ_LABEL,Window,0,0);
   return(0);
  }

//+------------------------------------------------------------------+
int deinit()
  {
//+------------------------------------------------------------------+
   ObjectDelete(objname);
   return(0);
  }

//+------------------------------------------------------------------+
int start()
  {
//+------------------------------------------------------------------+
   int R1=0,R5=0,R10=0;

   string   Text="";
   int j=0;

   R1 = (iHigh(NULL,PERIOD_D1,0)-iLow(NULL,PERIOD_D1,0))/pnt;
   for(j=1; j<=5; j++)
      R5    =    R5  + (iHigh(NULL,PERIOD_D1,j)-iLow(NULL,PERIOD_D1,j))/pnt;
   for(j=1; j<=10; j++)
      R10   =    R10 + (iHigh(NULL,PERIOD_D1,j)-iLow(NULL,PERIOD_D1,j))/pnt;

   R5 = R5/5;
   R10 = R10/10;
   double vol=iVolume(NULL,PERIOD_CURRENT,0);
   Text =   "ADR Today: " + R1 + "  5D: " + R5 + "  10D: " +  R10   + "\n";
   if((R1==R5 && vol<3)|| (R1==R10 && vol<3))
      Alert(Symbol()+"ADR LEVEL REACHED "+DoubleToStr(Bid,Digits));
   if(j>0 && pnt>0)
     {
      string objtext = (Text);
      ObjectSet(objname,OBJPROP_CORNER,Corner);
      ObjectSet(objname,OBJPROP_XDISTANCE,HorizPos);
      ObjectSet(objname,OBJPROP_YDISTANCE,VertPos);
      ObjectSetText(objname,objtext,FontSize,FontName,FontColor);
     }
   return(0);
  }

//+------------------------------------------------------------------+
