
#property copyright "Copyright 2015 HLL"
#property version   "2.0.5"


#property indicator_chart_window

color color_fuente = Black;
color color_fondo = White;
extern int Periodo =21;// Periodo
string fuente = "Arial";

int   w =0;
int   D =1160;

int tamaņo_fuente = 8;
int Derecha=190;
int Arrib=20;
int Medio=35;
int Abajo=50;
int Centro = 130;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 

//----
   return(0);
  }

//+------------------------------------------------------------------+
//|                          Indicadores                             |
//+------------------------------------------------------------------+
int start()
{
  IndicatorShortName("HLL");
  
  
//+-----------------------------------------------------------------+
//|                           Variables                             |
//+-----------------------------------------------------------------+

   double   spread = MarketInfo(Symbol(),MODE_SPREAD);
   double   deposito = MarketInfo(Symbol(), MODE_MARGINREQUIRED);
   double   tick = MarketInfo(Symbol(), MODE_TICKVALUE);
   double   stop = MarketInfo(Symbol(), MODE_STOPLEVEL);
   double   vs =  (MarketInfo(Symbol(), MODE_TICKVALUE))*( MarketInfo(Symbol(), MODE_SPREAD));
   double   ask = Ask;
   double   bid = Bid;
   double   volatilidad=(iATR(NULL,0,Periodo,1)/Point);
   double   vm = volatilidad/spread;
   datetime closetime=Time[0]+(Time[0]-Time[1])-TimeCurrent();
   
//      Variables Punto

   double M1Op=iOpen(Symbol(),1,0);
   double M1Cl=iClose(Symbol(),1,0);   
   double M5Op=iOpen(Symbol(),5,0);
   double M5Cl=iClose(Symbol(),5,0); 
   double M15Op=iOpen(Symbol(),15,0);
   double M15Cl=iClose(Symbol(),15,0); 
   double M30Op=iOpen(Symbol(),30,0);
   double M30Cl=iClose(Symbol(),30,0); 
   double H1Op=iOpen(Symbol(),60,0);
   double H1Cl=iClose(Symbol(),60,0); 
   double H4Op=iOpen(Symbol(),240,0);
   double H4Cl=iClose(Symbol(),240,0); 
   double D1Op=iOpen(Symbol(),1440,0);
   double D1Cl=iClose(Symbol(),1440,0); 
   double W1Op=iOpen(Symbol(),10080,0);
   double W1Cl=iClose(Symbol(),10080,0); 

//////////////////////////     
//      Creacion del Rectangulo

 
   ObjectCreate(0,"RECT",OBJ_RECTANGLE_LABEL,w,0,0);
   ObjectSetInteger(0,"RECT",OBJPROP_CORNER,ANCHOR_UPPER,1);
   ObjectSetInteger(0,"RECT",OBJPROP_BGCOLOR,color_fondo);
   //ObjectSetInteger(0,"RECT",OBJPROP_CORNER,0);
   ObjectSetInteger(0,"RECT",OBJPROP_XDISTANCE,Derecha+10);
   ObjectSetInteger(0,"RECT",OBJPROP_YDISTANCE,15);
   ObjectSetInteger(0,"RECT",OBJPROP_XSIZE,180);
   ObjectSetInteger(0,"RECT",OBJPROP_YSIZE,215);
   ObjectSetInteger(0,"RECT",OBJPROP_SELECTABLE,true);
 
//////////////////////////////////////////////////////////////////////////////   
   
   ObjectCreate("Spread", OBJ_LABEL, w,0,0);
   ObjectSetInteger(0,"Spread",OBJPROP_CORNER,ANCHOR_UPPER,1);
   //ObjectSet("Spread",OBJPROP_CORNER,0);
   ObjectSet("Spread", OBJPROP_XDISTANCE, Derecha);
   ObjectSet("Spread", OBJPROP_YDISTANCE, 20);
   
   ObjectCreate("Ask", OBJ_LABEL, w,0,0);
   ObjectSetInteger(0,"Ask",OBJPROP_CORNER,ANCHOR_UPPER,1);
   //ObjectSet("Ask",OBJPROP_CORNER,0);
   ObjectSet("Ask", OBJPROP_XDISTANCE,Derecha);
   ObjectSet("Ask", OBJPROP_YDISTANCE, 35);
   
   ObjectCreate("Bid", OBJ_LABEL, w,0,0);
   ObjectSetInteger(0,"Bid",OBJPROP_CORNER,ANCHOR_UPPER,1);
   //ObjectSet("Bid",OBJPROP_CORNER,0);
   ObjectSet("Bid", OBJPROP_XDISTANCE,Derecha);
   ObjectSet("Bid", OBJPROP_YDISTANCE, 50);

 ///////////////////////////////////////////////////////////////////////////////
   
   ObjectCreate("Volatilidad", OBJ_LABEL, w,0,0);
   ObjectSetInteger(0,"Volatilidad",OBJPROP_CORNER,ANCHOR_UPPER,1);
   //ObjectSet("Volatilidad",OBJPROP_CORNER,0);
   ObjectSet("Volatilidad", OBJPROP_XDISTANCE,Derecha);
   ObjectSet("Volatilidad", OBJPROP_YDISTANCE, 65);
   
   ObjectCreate("VM", OBJ_LABEL, w,0,0);
   ObjectSetInteger(0,"VM",OBJPROP_CORNER,ANCHOR_UPPER,1);
   //ObjectSet("VM",OBJPROP_CORNER,0);
   ObjectSet("VM", OBJPROP_XDISTANCE,Derecha);
   ObjectSet("VM", OBJPROP_YDISTANCE, 80);
   
   ObjectCreate("Time_remain",OBJ_LABEL,w,0,0);
   ObjectSetInteger(0,"Time_remain",OBJPROP_CORNER,ANCHOR_UPPER,1);
   //ObjectSet("Time_remain",OBJPROP_CORNER,0);
   ObjectSet("Time_remain",OBJPROP_XDISTANCE,Derecha);
   ObjectSet("Time_remain",OBJPROP_YDISTANCE,95);

/////////////////////////////////////////////////////////////////////////////////////

   ObjectCreate("Nominal", OBJ_LABEL, w,0,0);
   ObjectSetInteger(0,"Nominal",OBJPROP_CORNER,ANCHOR_UPPER,1);
   //ObjectSet("Nominal",OBJPROP_CORNER,0);
   ObjectSet("Nominal", OBJPROP_XDISTANCE,Derecha);
   ObjectSet("Nominal", OBJPROP_YDISTANCE, 110);
   
   ObjectCreate("Deposito", OBJ_LABEL, w,0,0);
   ObjectSetInteger(0,"Deposito",OBJPROP_CORNER,ANCHOR_UPPER,1);
   //ObjectSet("Deposito",OBJPROP_CORNER,0);
   ObjectSet("Deposito", OBJPROP_XDISTANCE,Derecha);
   ObjectSet("Deposito", OBJPROP_YDISTANCE, 125);
   
   ObjectCreate("Tick", OBJ_LABEL, w,0,0);
   ObjectSetInteger(0,"Tick",OBJPROP_CORNER,ANCHOR_UPPER,1);
   //ObjectSet("Tick",OBJPROP_CORNER,0);
   ObjectSet("Tick", OBJPROP_XDISTANCE,Derecha);
   ObjectSet("Tick", OBJPROP_YDISTANCE, 140);
   
   ObjectCreate("VS", OBJ_LABEL, w,0,0);
   ObjectSetInteger(0,"VS",OBJPROP_CORNER,ANCHOR_UPPER,1);
   //ObjectSet("VS",OBJPROP_CORNER,0);
   ObjectSet("VS", OBJPROP_XDISTANCE,Derecha);
   ObjectSet("VS", OBJPROP_YDISTANCE, 155);
   
   ObjectCreate("Stop", OBJ_LABEL, w,0,0);
   ObjectSetInteger(0,"Stop",OBJPROP_CORNER,ANCHOR_UPPER,1);
   //ObjectSet("Stop",OBJPROP_CORNER,0);
   ObjectSet("Stop", OBJPROP_XDISTANCE,Derecha);
   ObjectSet("Stop", OBJPROP_YDISTANCE, 170);
   

      
   ObjectCreate("name", OBJ_LABEL, w,0,0);
   ObjectSetInteger(0,"name",OBJPROP_CORNER,ANCHOR_UPPER,1);
   //ObjectSet("name",OBJPROP_CORNER,0);
   ObjectSet("name",OBJPROP_XDISTANCE,Derecha);
   ObjectSet("name",OBJPROP_YDISTANCE,185);

////////////////////////////////////////////////////////////////////////////////////
      
      ObjectCreate("M1", OBJ_LABEL, w,0,0);
      //ObjectSetText("M1",CharToStr(108),10,"Wingdings"); 
      ObjectSetInteger(0,"M1",OBJPROP_CORNER,ANCHOR_UPPER,1);     
      //ObjectSet("M1",OBJPROP_CORNER,0);
      ObjectSet("M1",OBJPROP_XDISTANCE,Derecha);
      ObjectSet("M1",OBJPROP_YDISTANCE,200);

      ObjectCreate("M5", OBJ_LABEL, w,0,0);
      ObjectSetInteger(0,"M5",OBJPROP_CORNER,ANCHOR_UPPER,1);     
     // ObjectSet("M5",OBJPROP_CORNER,0);
      ObjectSet("M5",OBJPROP_XDISTANCE,Derecha-22);
      ObjectSet("M5",OBJPROP_YDISTANCE,200);
      
      ObjectCreate("M15", OBJ_LABEL, w,0,0); 
      ObjectSetInteger(0,"M15",OBJPROP_CORNER,ANCHOR_UPPER,1);    
      //ObjectSet("M15",OBJPROP_CORNER,0);
      ObjectSet("M15",OBJPROP_XDISTANCE,Derecha-44);
      ObjectSet("M15",OBJPROP_YDISTANCE,200);
      
      ObjectCreate("M30", OBJ_LABEL, w,0,0);
      ObjectSetInteger(0,"M30",OBJPROP_CORNER,ANCHOR_UPPER,1);     
      //ObjectSet("M30",OBJPROP_CORNER,0);
      ObjectSet("M30",OBJPROP_XDISTANCE,Derecha-66);
      ObjectSet("M30",OBJPROP_YDISTANCE,200);
      
      ObjectCreate("1H", OBJ_LABEL, w,0,0); 
      ObjectSetInteger(0,"1H",OBJPROP_CORNER,ANCHOR_UPPER,1);    
      //ObjectSet("1H",OBJPROP_CORNER,0);
      ObjectSet("1H",OBJPROP_XDISTANCE,Derecha-88);
      ObjectSet("1H",OBJPROP_YDISTANCE,200);
      
      ObjectCreate("4H", OBJ_LABEL, w,0,0);
      ObjectSetInteger(0,"4H",OBJPROP_CORNER,ANCHOR_UPPER,1);     
      //ObjectSet("4H",OBJPROP_CORNER,0);
      ObjectSet("4H",OBJPROP_XDISTANCE,Derecha-110);
      ObjectSet("4H",OBJPROP_YDISTANCE,200);
      
      ObjectCreate("D1", OBJ_LABEL, w,0,0); 
      ObjectSetInteger(0,"D1",OBJPROP_CORNER,ANCHOR_UPPER,1);    
      //ObjectSet("D1",OBJPROP_CORNER,0);
      ObjectSet("D1",OBJPROP_XDISTANCE,Derecha-132);
      ObjectSet("D1",OBJPROP_YDISTANCE,200);

      ObjectCreate("W1", OBJ_LABEL, w,0,0);
      ObjectSetInteger(0,"W1",OBJPROP_CORNER,ANCHOR_UPPER,1);     
      //ObjectSet("W1",OBJPROP_CORNER,0);
      ObjectSet("W1",OBJPROP_XDISTANCE,Derecha-154);
      ObjectSet("W1",OBJPROP_YDISTANCE,200);

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+


   RefreshRates();
 
//       Spread  

      ObjectSetText("Spread", "Spread: "+ spread +"  Pips", 10, fuente, color_fuente);
      
//       Ask

      ObjectSetText("Ask", "Ask: "+ ask, 10, fuente, Red);

//       Bid

      ObjectSetText("Bid", "Bid: "+ bid, 10, fuente, Green);
  
//       Volatilidad
   
      ObjectSetText("Volatilidad", "Volatilidad: "+ NormalizeDouble(volatilidad,2) +"  Pips", 10, fuente, Blue);

//        Veces Mayor

      ObjectSetText("VM", "Veces Mayor: "+ NormalizeDouble(vm,2) +"  Veces", 10, fuente, Blue);
      
//       Tiempo
     
      ObjectSetText("Time_remain",StringConcatenate("Tiempo restante:  ",TimeToStr(closetime,TIME_SECONDS)),10,fuente,Orchid);
   
//       Nominal

      ObjectSetText("Nominal", "Valor Nominal: 1.00 lotes", tamaņo_fuente, fuente, color_fuente);

//       Deposito

      ObjectSetText("Deposito", "Deposito: "+ deposito +"  EUR", tamaņo_fuente, fuente, color_fuente);

//       Tick

      ObjectSetText("Tick", "Valor del tick: "+ NormalizeDouble(tick,4) +"  EUR", tamaņo_fuente, fuente, color_fuente);
      
//       Valor del Spread

      ObjectSetText("VS", "Valor del Spread: "+ NormalizeDouble(vs,4) +"  EUR", tamaņo_fuente, fuente, color_fuente);

//       Stop

      ObjectSetText("Stop", "Nivel de stop: "+ NormalizeDouble(stop,2) +"  Ticks", tamaņo_fuente, fuente, color_fuente);
      
//       Timefreq

      ObjectSetText("name", "1M  5M  15M  30M  1H  4H  1D  W1", tamaņo_fuente, fuente, color_fuente);
      
//       Puntos

        if(M1Cl>M1Op){ObjectSetText("M1",CharToStr(108),10,"Wingdings",Green);} if(M1Cl<M1Op) {ObjectSetText("M1",CharToStr(108),10,"Wingdings",Red);}
        if(M1Cl==M1Op) {ObjectSetText("M1",CharToStr(108),10,"Wingdings",Gold);}
        if(M5Cl>M5Op){ObjectSetText("M5",CharToStr(108),10,"Wingdings",Green);} if(M5Cl<M5Op) {ObjectSetText("M5",CharToStr(108),10,"Wingdings",Red);}
        if(M5Cl==M5Op) {ObjectSetText("M5",CharToStr(108),10,"Wingdings",Gold);}
        if(M15Cl>M15Op){ObjectSetText("M15",CharToStr(108),10,"Wingdings",Green);} if(M15Cl<M15Op) {ObjectSetText("M15",CharToStr(108),10,"Wingdings",Red);}
        if(M15Cl==M15Op) {ObjectSetText("M15",CharToStr(108),10,"Wingdings",Gold);}
        if(M30Cl>M30Op){ObjectSetText("M30",CharToStr(108),10,"Wingdings",Green);} if(M30Cl<M30Op) {ObjectSetText("M30",CharToStr(108),10,"Wingdings",Red);}
        if(M30Cl==M30Op) {ObjectSetText("M30",CharToStr(108),10,"Wingdings",Gold);}
        if(H1Cl>H1Op){ObjectSetText("1H",CharToStr(108),10,"Wingdings",Green);} if(H1Cl<H1Op) {ObjectSetText("1H",CharToStr(108),10,"Wingdings",Red);}
        if(H1Cl==H1Op) {ObjectSetText("1H",CharToStr(108),10,"Wingdings",Gold);}
        if(H4Cl>H4Op){ObjectSetText("4H",CharToStr(108),10,"Wingdings",Green);} if(H4Cl<H4Op) {ObjectSetText("4H",CharToStr(108),10,"Wingdings",Red);}
        if(H4Cl==H4Op) {ObjectSetText("4H",CharToStr(108),10,"Wingdings",Gold);}
        if(D1Cl>D1Op){ObjectSetText("D1",CharToStr(108),10,"Wingdings",Green);} if(D1Cl<D1Op) {ObjectSetText("D1",CharToStr(108),10,"Wingdings",Red);}
        if(D1Cl==D1Op) {ObjectSetText("D1",CharToStr(108),10,"Wingdings",Gold);}
        if(W1Cl>W1Op){ObjectSetText("W1",CharToStr(108),10,"Wingdings",Green);} if(W1Cl<W1Op) {ObjectSetText("W1",CharToStr(108),10,"Wingdings",Red);}
        if(W1Cl==W1Op) {ObjectSetText("W1",CharToStr(108),10,"Wingdings",Gold);}            
          
      
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{

   ObjectDelete("RECT");
   ObjectDelete("Spread");
   ObjectDelete("Ask");
   ObjectDelete("Bid");
   ObjectDelete("Volatilidad");
   ObjectDelete("VM");
   ObjectDelete("Time_remain");   
   ObjectDelete("Nominal");
   ObjectDelete("Deposito");
   ObjectDelete("Tick");
   ObjectDelete("Stop");
   ObjectDelete("VS");
   ObjectDelete("name");
   ObjectDelete("M1");
   ObjectDelete("M5");
   ObjectDelete("M15");
   ObjectDelete("M30");
   ObjectDelete("1H");
   ObjectDelete("4H");
   ObjectDelete("D1");
   ObjectDelete("W1");
   

   return(0);
}

   
/*
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,         // Event identifier  
                  const long& lparam,   // Event parameter of long type
                  const double& dparam, // Event parameter of double type
                  const string& sparam) // Event parameter of string type
  {
    
//--- the mouse has been clicked on the graphic object
int X = lparam;
int Y = dparam;

   if(id==CHARTEVENT_CLICK)
      {
      Comment("The coordinates of the mouse click on the chart are: x = ",X,"  y = ",Y);
      }

 }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
*/