//+------------------------------------------------------------------+
//|                                                                  |
//|         Information + Range V1.0 Lite                            |
//|          Modified by ANGUS.                                      |
//+------------------------------------------------------------------+

#property copyright "Copyright © 2009"
#property link      "Angus of ForexFactory.com"

#property indicator_chart_window
 
extern int   ATR1_Prd            = 5;
extern int   ATR2_Prd            = 20;
extern int   Which_Cnr           = 0;
extern int   Shift_UP_DN         = -50;
extern int   Adjust_Side_to_side = 0;
extern color CommentLabel_color  = White;
extern color Prc_Up_Color        = MediumSeaGreen;
extern color Prc_Dn_Color        = DarkSalmon;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectsDeleteAll(0,OBJ_LABEL); 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {    
   //Info 
   color  PrcColor;
   string PRC1;
   double Price1 = iMA(Symbol(),0,1,0,MODE_EMA,PRICE_CLOSE,0);
   double xec=1; if(Digits==5||Digits==3){xec=10;}
   double PrcOpen = iOpen(NULL,0,0);
   double PrcClose = iClose(NULL,0,0);
     
    PRC1 = DoubleToStr(Price1,Digits);
    
    if (PrcOpen > PrcClose) PrcColor = Prc_Dn_Color;
    if (PrcOpen < PrcClose) PrcColor = Prc_Up_Color;
    if (PrcOpen == PrcClose) PrcColor = Gold;
          
// Price Label
  
   ObjectCreate("Price1", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Price1",""+PRC1+"", 24, "Arial",  PrcColor);
   ObjectSet("Price1", OBJPROP_CORNER,Which_Cnr);
   ObjectSet("Price1", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side);
   ObjectSet("Price1", OBJPROP_YDISTANCE, 68+Shift_UP_DN); 

//---------------------------------------------------------------
          
   int R1=0,R5=0,R10=0,R20=0,RAvg=0,i=0;
   R1 =  (iHigh(NULL,PERIOD_D1,1)-iLow(NULL,PERIOD_D1,1))/Point;
   for(i=1;i<=5;i++)
      R5    =    R5  +  (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/Point;
   for(i=1;i<=10;i++)
      R10   =    R10 +  (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/Point;
   for(i=1;i<=20;i++)
      R20   =    R20 +  (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/Point;

   R5 = R5/5;
   R10 = R10/10;
   R20 = R20/20;
   RAvg  =  ((R1+R5+R10+R20)/4)/xec;
   
//--------------------------------------------------------------  
                
   string HI="",LO="",SPREAD="",PIPS="",DAV="",HILO="",PRC,Pips="",Av="",AV_Yest="",TBAR="";
   int ATR1,ATR2;
   color color_pip,color_av,atr_color,tbar_color;
   
   double low0  =  iLow(NULL,PERIOD_D1,0);
   double high0 =  iHigh(NULL,PERIOD_D1,0);
   double OPEN = iOpen(NULL,1440,0);
   double CLOSE = iClose(NULL,1440,0);
   double TOPEN = iOpen(NULL,0,0);
   double TCLOSE = iClose(NULL,0,0);
   double SPRD = (Ask - Bid)/Point;
   double High_Today = iHigh(NULL,1440,0);
   double Low_Today = iLow(NULL,1440,0);
   double xecn=1; if(Digits==5||Digits==3){xecn=10;}
   double point; point=Point;
   
      if( Digits==3 || Digits==5 ) point=point*10;
         
   ATR1=MathRound(iATR(NULL,0,ATR1_Prd,1)/point);
   ATR2=MathRound(iATR(NULL,0,ATR2_Prd,1)/point);
            
   PIPS =  DoubleToStr(((CLOSE-OPEN)/xecn)/Point,0);
   TBAR =  DoubleToStr(((TCLOSE-TOPEN)/xecn)/Point,0);
   SPREAD = (DoubleToStr((SPRD/xecn),Digits-4));
   DAV = (DoubleToStr(RAvg,Digits-5));
   AV_Yest =  ((iHigh(NULL,PERIOD_D1,1)-iLow(NULL,PERIOD_D1,1))/Point)/xecn;
   HILO = DoubleToStr(((High_Today-Low_Today)/xecn)/Point,0);
         
     if (StringFind(Symbol(),"JPY",0) != -1)
   {
   SPREAD = (DoubleToStr((SPRD/xecn),Digits-2));
   DAV = (DoubleToStr(RAvg,Digits-4));
   }
          
     if (CLOSE >= OPEN) {Pips= "-";color_pip = Lime; }
     if (CLOSE < OPEN) {Pips= "-";color_pip = Red; }
     if (DAV > AV_Yest) {Av= "-";color_av = Lime; }
     if (DAV < AV_Yest) {Av= "-";color_av = Red; }
     if (ATR1 > ATR2) {atr_color = Lime;}
     if (ATR1 < ATR2) {atr_color = Red;}
     if (ATR1 == ATR2) {atr_color = Gold;}
     if (TCLOSE >= TOPEN) {tbar_color = Lime;}
     if (TCLOSE < TOPEN) {tbar_color = Red;}
     
//Info Labels
                  
                ObjectCreate("Info1", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Info1","Spread", 10, "Arial", CommentLabel_color);
   ObjectSet("Info1", OBJPROP_CORNER,Which_Cnr);
   ObjectSet("Info1", OBJPROP_XDISTANCE, 45+Adjust_Side_to_side);
   ObjectSet("Info1", OBJPROP_YDISTANCE, 100+Shift_UP_DN); 
   
               ObjectCreate("Info2", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Info2",""+SPREAD+"", 10, "Arial Bold", Gold);
   ObjectSet("Info2", OBJPROP_CORNER,Which_Cnr);
   ObjectSet("Info2", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side);
   ObjectSet("Info2", OBJPROP_YDISTANCE, 100+Shift_UP_DN);  
   
     
                ObjectCreate("Info3", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Info3","Pips to Open", 10, "Arial", CommentLabel_color);
   ObjectSet("Info3", OBJPROP_CORNER,Which_Cnr);
   ObjectSet("Info3", OBJPROP_XDISTANCE, 45+Adjust_Side_to_side);
   ObjectSet("Info3", OBJPROP_YDISTANCE, 115+Shift_UP_DN); 
   
               ObjectCreate("Info4", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Info4",""+PIPS+"", 10, "Arial Bold", color_pip);
   ObjectSet("Info4", OBJPROP_CORNER,Which_Cnr);
   ObjectSet("Info4", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side);
   ObjectSet("Info4", OBJPROP_YDISTANCE, 115+Shift_UP_DN);  
      
                ObjectCreate("Info5", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Info5","Hi to Low", 10, "Arial", CommentLabel_color);
   ObjectSet("Info5", OBJPROP_CORNER,Which_Cnr);
   ObjectSet("Info5", OBJPROP_XDISTANCE, 45+Adjust_Side_to_side);
   ObjectSet("Info5", OBJPROP_YDISTANCE, 130+Shift_UP_DN); 
   
               ObjectCreate("Info6", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Info6",""+HILO+"", 10, "Arial Bold", Gold);
   ObjectSet("Info6", OBJPROP_CORNER,Which_Cnr);
   ObjectSet("Info6", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side);
   ObjectSet("Info6", OBJPROP_YDISTANCE, 130+Shift_UP_DN);  
   
                 ObjectCreate("Info7", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Info7","Daily Av", 10, "Arial",CommentLabel_color);
   ObjectSet("Info7", OBJPROP_CORNER,Which_Cnr);
   ObjectSet("Info7", OBJPROP_XDISTANCE, 45+Adjust_Side_to_side);
   ObjectSet("Info7", OBJPROP_YDISTANCE, 145+Shift_UP_DN); 
   
               ObjectCreate("Info8", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Info8",""+DAV+"", 10, "Arial Bold", color_av);
   ObjectSet("Info8", OBJPROP_CORNER,Which_Cnr);
   ObjectSet("Info8", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side);
   ObjectSet("Info8", OBJPROP_YDISTANCE, 145+Shift_UP_DN); 
   
              ObjectCreate("Info9", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Info9","Atr ["+ATR1_Prd+"]", 10, "Arial",CommentLabel_color);
   ObjectSet("Info9", OBJPROP_CORNER,Which_Cnr);
   ObjectSet("Info9", OBJPROP_XDISTANCE, 45+Adjust_Side_to_side);
   ObjectSet("Info9", OBJPROP_YDISTANCE, 160+Shift_UP_DN); 
   
               ObjectCreate("Info10", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Info10",""+ATR1+"", 10, "Arial Bold", atr_color);
   ObjectSet("Info10", OBJPROP_CORNER,Which_Cnr);
   ObjectSet("Info10", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side);
   ObjectSet("Info10", OBJPROP_YDISTANCE, 160+Shift_UP_DN); 
   
               ObjectCreate("Info11", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Info11","Atr ["+ATR2_Prd+"]", 10, "Arial",CommentLabel_color);
   ObjectSet("Info11", OBJPROP_CORNER,Which_Cnr);
   ObjectSet("Info11", OBJPROP_XDISTANCE, 45+Adjust_Side_to_side);
   ObjectSet("Info11", OBJPROP_YDISTANCE, 175+Shift_UP_DN); 
   
               ObjectCreate("Info12", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Info12",""+ATR2+"", 10, "Arial Bold", atr_color);
   ObjectSet("Info12", OBJPROP_CORNER,Which_Cnr);
   ObjectSet("Info12", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side);
   ObjectSet("Info12", OBJPROP_YDISTANCE, 175+Shift_UP_DN); 
   
               ObjectCreate("Info13", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Info13","This Bar", 10, "Arial",CommentLabel_color);
   ObjectSet("Info13", OBJPROP_CORNER,Which_Cnr);
   ObjectSet("Info13", OBJPROP_XDISTANCE, 45+Adjust_Side_to_side);
   ObjectSet("Info13", OBJPROP_YDISTANCE, 190+Shift_UP_DN); 
   
               ObjectCreate("Info14", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Info14",""+TBAR+"", 10, "Arial Bold", tbar_color);
   ObjectSet("Info14", OBJPROP_CORNER,Which_Cnr);
   ObjectSet("Info14", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side);
   ObjectSet("Info14", OBJPROP_YDISTANCE, 190+Shift_UP_DN); 



 //*****************************************************************

   return(0);
  }
//+------------------------------------------------------------------+