//+------------------------------------------------------------------+
//|                                               Rango_Rotacion.mq4 |
//|                      Copyright © 2008, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"


#property indicator_separate_window

#property indicator_buffers 1
#property indicator_color1 DodgerBlue

double Buffer[];

extern int barras = 500;


int init()
  {
   IndicatorBuffers(1);

   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Buffer);

   IndicatorShortName("Rango_Rotación");
   SetIndexLabel(0,"Rango_Rotación");
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
int i,total,max,min;


for(i=barras;i>0;i--)
{
   if(iHigh(Symbol(),0,i)>iHigh(Symbol(),0,i+1)) max = 1;
   if(iHigh(Symbol(),0,i)<iHigh(Symbol(),0,i+1)) max = -1;
   if(iHigh(Symbol(),0,i)==iHigh(Symbol(),0,i+1)) max = 0;
   if(iLow(Symbol(),0,i)>iLow(Symbol(),0,i+1)) min = 1;
   if(iLow(Symbol(),0,i)<iLow(Symbol(),0,i+1)) min = -1;
   if(iLow(Symbol(),0,i)==iLow(Symbol(),0,i+1)) min = 0;
   total = total+(max+min);
   Buffer[i] = total;
}
   
   return(0);
  }
//+------------------------------------------------------------------+