#property copyright "tigpips-Modificado por MF1Forex 2015"
#property link      "tigpips"

#property indicator_chart_window
#property indicator_buffers 4

#property indicator_color1 SkyBlue
#property indicator_color2 SkyBlue
#property indicator_color3 SkyBlue
#property indicator_color4 SkyBlue
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 4
#property indicator_width4 4

extern color color1 = SkyBlue;
extern double pips = 20.0;
extern bool AlertMessage = true;
extern bool AlertSound   = true;
extern bool AlertPush    =false;

double buffer1[],buffer2[],buffer3[],buffer4[];

int init()
{
//---- indicators
 SetIndexStyle(0,DRAW_HISTOGRAM,0,1,color1);
 SetIndexBuffer(0,buffer1);
 SetIndexStyle(1,DRAW_HISTOGRAM,0,1,color1);
 SetIndexBuffer(1,buffer2);
 SetIndexStyle(2,DRAW_HISTOGRAM,0,4,color1);
 SetIndexBuffer(2,buffer3);
 SetIndexStyle(3,DRAW_HISTOGRAM,0,4,color1);
 SetIndexBuffer(3,buffer4);
//----
 return(0);
}

int deinit()
{

 return(0);
}

int start()
{   
 int i,direction,imax,counted_bars=IndicatorCounted();
 if(counted_bars>0) imax=Bars-IndicatorCounted();
 else imax=Bars-1;    
//----
 for(i=imax;i>=0;i--) 
 {
  Resetall(i);
  direction=GetBar(i);
  if(direction>0)
  {
   buffer1[i] = iHigh(NULL,0,i);
   buffer2[i] = iLow(NULL,0,i);  
   buffer3[i] = iOpen(NULL,0,i);
   buffer4[i] = iClose(NULL,0,i); 
   
   if (AlertMessage) Alert("Vela superior a ", pips, " Pips");
   if (AlertSound) PlaySound("alert.wav");
   if (AlertPush)  SendNotification("Vela superior en indicador: Color Candles");
  }
 } 
//----
 return(0);
}

void Resetall(int shift) 
{
 buffer1[shift] = EMPTY_VALUE;
 buffer2[shift] = EMPTY_VALUE;
 buffer3[shift] = EMPTY_VALUE;
 buffer4[shift] = EMPTY_VALUE;
 return;
}
//+------------------------------------------------------------------+
int GetBar(int shift) 
{
 double open=iOpen(NULL,0,shift);
 double close=iClose(NULL,0,shift);
 double high=iHigh(NULL,0,shift);
 double low=iLow(NULL,0,shift);
 int buffer;
 double range;
 if(Digits == 4)
 {
   buffer = 1000;
 }
 else if(Digits == 5)
 {
   buffer = 10000;
 }
 range=MathAbs(close-open);
 if (range*buffer >= pips) 
 {
   return (1);
 }
 else
 {
   return(0);
 }

}