//+------------------------------------------------------------------+
//|                                                 Indicador_00.mq4 |
//|                                             Copyright 2012, ELO. |
//|                                           http://www.citrelo.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, ELO."
#property link      "http://www.citrelo.com"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Green

#define TIPO_VENTA  100
#define TIPO_COMPRA 101
#define TIPO_IGUAL  102

extern bool MostrarColor = false;

double ExtBufferPrecio[];
int    iExtIndice = 0;

double dPrecioAsk = 0;
double dPrecioBid = 0;   

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   SetIndexBuffer(0, ExtBufferPrecio);
   SetIndexStyle(0,DRAW_LINE,0,2);
   
   //-----
   IndicatorShortName("Price ELO");
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   //int counted_bars = IndicatorCounted();
   
   LeerDatos();
   
   return(0);
}

void LeerDatos()
{  
   int i = 0;
   int iTipo = 0; 
     
   //----- Tipo del Tick (Compra/Venta)
   if(dPrecioAsk == Ask)
   {
      if(MostrarColor) SetIndexStyle(0, DRAW_LINE, 0, 2, Yellow);
      iTipo = TIPO_IGUAL;   
   }
   if(dPrecioAsk > Ask)
   {
      if(MostrarColor) SetIndexStyle(0, DRAW_LINE, 0, 2, Red);
      iTipo = TIPO_VENTA;   
   }
   if(dPrecioAsk < Ask)
   {
      if(MostrarColor) SetIndexStyle(0, DRAW_LINE, 0, 2, Green);   
      iTipo = TIPO_COMPRA;
   }
   
   //----- Leer Precios
   dPrecioAsk = Ask;
   dPrecioBid = Bid;
   
 
   //----- Desplazar los valores. Ultimo precio a la derecha (Index = 0)
   for(i = iExtIndice; i >= 0; i--)
   {
      ExtBufferPrecio[i+1] = ExtBufferPrecio[i];    
   }
   //----- Nuevo nivel de precios
   ExtBufferPrecio[0] = dPrecioAsk;                                    
   
   //----- Sólo contemplamos 1000 valores
   iExtIndice++;
   if(iExtIndice > 1000)
      iExtIndice = 1000;
      
}
//+------------------------------------------------------------------+