Help Need

 
Hello everyone

I'm working in this Adx Arrow Alert, the thing is it works but it only work 1 time, let me expleand, when the arrow (Red or Green) shows-up it send me the alert as has to be, but when the next arrow apper it don't do nothing, can someone can help me whit this.. i'am new in this things of programing. :)

//+------------------------------------------------------------------+
//| ADX DOTS W/ALARM                                                 |
//|                                                                  |
//+------------------------------------------------------------------+
 
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
 
// parametros
extern int ADXbars=14;
extern int CB=350;
extern int Temp=0;
 
// buffers
double var1[];
double var2[];
 
double ppdi,npdi,pmdi,nmdi;
 
//+------------------------------------------------------------------+
//| Funcion de Inicio del Indicador                                  |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,108);
   SetIndexBuffer(0,var1);  
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,108);
   SetIndexBuffer(1,var2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Señal "ARROW"                                                    |
//+------------------------------------------------------------------+
int start()
  {   
   if (CB>=Bars) CB=Bars;
   SetIndexDrawBegin(0,Bars-CB);
   SetIndexDrawBegin(1,Bars-CB);
   int i,updata,counted_bars=IndicatorCounted();
 
 
   //---- check for possible errors
   if(counted_bars<0) return(-1);
 
   //---- initial zero
   if(counted_bars<1)
     {
      for(i=1;i<=CB;i++) var1[CB-i]=0.0;
      for(i=1;i<=CB;i++) var2[CB-i]=0.0;
            
     } 
     
for (updata = CB; updata>=0; updata--)
 
{ 
 
    ppdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_PLUSDI,updata-1);
    npdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_PLUSDI,updata);
    pmdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_MINUSDI,updata-1);
    nmdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_MINUSDI,updata); 
if (ppdi>pmdi && npdi<nmdi)
{
   var2[updata]=Low[updata]-5*Point;
   Comment ("COMPRA");
}
if (ppdi<pmdi && npdi>nmdi)
{
   var2[updata]=High[updata]+5*Point;
   Comment ("VENTA");
}
}
 
//+------------------------------------------------------------------+
//| Señal de Alerta                                                  |
//+------------------------------------------------------------------+
 
{
   ppdi=iADX(NULL,0,14,PRICE_CLOSE,MODE_PLUSDI,1);
   npdi=iADX(NULL,0,14,PRICE_CLOSE,MODE_PLUSDI,0);
   pmdi=iADX(NULL,0,14,PRICE_CLOSE,MODE_MINUSDI,1);
   nmdi=iADX(NULL,0,14,PRICE_CLOSE,MODE_MINUSDI,0);
   
      if (ppdi>pmdi && npdi<nmdi && Temp<2)
      {
      Alert("-=Venta=- @ "+ Symbol()+" "+Period()+"M","\n","Dia ",Day()," Del Mes ",Month());  
      Temp++;    
          return(0);
      }
     
         
      if (ppdi<pmdi && npdi>nmdi && Temp<2)
       {
      Alert("-=Compra=- @ "+Symbol()+" "+Period()+"M","\n","Dia ",Day()," Del Mes ",Month());    
      Temp++;
            return(0);
      }
      
 
 }
 
 
   return(0);
  }
//+------------------------------------------------------------------+

i thing is something very simple, but if i try to remove the Temp, each tick on the bar, the alerts will appear, and that thing is not cool, (too much noise)

Thanks again
 
// It has a error:::

if (ppdi>pmdi && npdi<nmdi)
{
var2[updata]=Low[updata]-5*Point;
Comment ("COMPRA");
}

// has to be :::::
if (ppdi>pmdi && npdi<nmdi)
{
var1[updata]=Low[updata]-5*Point;
Comment ("COMPRA");
}

Thanks
Reason: