Double Max and Double Min:

 

 Hello everyone, I have the following function that gives me a allert when when you come to form the double up and double min:

 

void DoppioMinMax(int DistanzaFrecciaRib=5, int DistanzaFrecciaRia=5, )
{
  int dpmindmax =0;
  int i, countDmax=0, countdpmin=0;
   for (i = Bars-10; i >= 0; i--) 
    {
     
    // CercoDoppioMassimo
     if (Close[i+2]>Open[i+2] && Close[i+1]<Open[i+1] && Close[i+2]<=(Open[i+1]+Margine*Poin) && Close[i+2]>=(Open[i+1]-Margine*Poin)){
         DoppioMassimo[i+1]=High[i+1]+DistanzaFrecciaRib*Poin;
         dpmindmax=1;
         countDmax++;
         //Alert("Sell su:"+Symbol()+" a TF "+IntegerToString(Period(),0,0));
         if (NuovaCandela()==True)
            Alert("Sell su:"+Symbol()+" a TF "+IntegerToString(Period(),0,0));
            }
    
     if (Close[i+2]<Open[i+2] && Close[i+1]>Open[i+1] && Close[i+2]<=(Open[i+1]+Margine*Poin) && Close[i+2]>=(Open[i+1]-Margine*Poin)){
         DoppioMinimo[i+1]=Low[i+1]-DistanzaFrecciaRia*Poin;
         dpmindmax=2;
         //Alert("Buy su:"+Symbol()+" a TF "+IntegerToString(Period(),0,0));
         countdpmin++;
         if (NuovaCandela()==True)
             Alert("Buy su:"+Symbol()+" a TF "+IntegerToString(Period(),0,0));
                                       }
         
         Comment("doppio max:"+ countDmax +"\ndoppio min:" +countdpmin+"\ndoppiominmax:" +dpmindmax);
       }          
                        
      } 

 The problem is that the function I from the allert each time you that closes a bar even if it is not a double dip or a double top to me would serve the

allert only when there is a double min or a double top, you know help me?

 
texcs: I get the alert each time a bar closes
  1. Then drop your loop and only look at bars 1 and 2.
  2. Your text is almost incomprehensible. If you are using mechanical translation, you must use simple sentence structure.
 
WHRoeder:
texcs: I get the alert each time a bar closes
  1. Then drop your loop and only look at bars 1 and 2.
  2. Your text is almost incomprehensible. If you are using mechanical translation, you must use simple sentence structure.

The problem with this function is that it gives me the alert signal each time you close a candel and it opens a new one;
Instead of this I need to have the alert signal every time it forms a double minus or a double maxium, only in these two cases. 
 
texcs:

The problem with this function is that it gives me the alert signal each time you close a candel and it opens a new one;
Instead of this I need to have the alert signal every time it forms a double minus or a double maxium, only in these two cases. 

WHRoeder has already given you the answer (and you even quoted him), yet you did not do it!

WHRoeder:
texcs: I get the alert each time a bar closes
  1. Then drop your loop and only look at bars 1 and 2.
 
  for (i = Bars-10; i >= 0; i--)
    {
    
     // CercoDoppioMassimo
     if (Close[i+2]>Open[i+2] && Close[i+1]<Open[i+1] && Close[i+2]<=(Open[i+1]+Margine*Poin) && Close[i+2]>=(Open[i+1]-Margine*Poin)&& (High[i+2]< High[i+1])&&(Low[i+2]>Low[i+1]))
     {  
    
         DoppioMassimo[i+1]=High[i+1]+DistanzaFrecciaRib*Poin;
         //Alert("Doppio Massimo su "+Symbol()+" a TF "+IntegerToString(Period(),0,0));
     }
    
     if (Close[i+2]<Open[i+2] && Close[i+1]>Open[i+1] && Close[i+2]<=(Open[i+1]+Margine*Poin) && Close[i+2]>=(Open[i+1]-Margine*Poin)&&(Low[i+2]> Low[i+1])&&(High[i+2]<High[i+1])&& (Close[i+1]<Open [i+2]))
     {
      DoppioMinimo[i+1]=Low[i+1]-DistanzaFrecciaRia*Poin;
      //Alert("Doppio Minimo su "+Symbol()+" a TF "+IntegerToString(Period(),0,0));0
     }


double max and double min function has to create a red arrow for any double max and (which do not appear everytime) and 1 green arrow for every double min (which never appear) who help me to fix (i attach the candle which has to recognize the functions)

 
texoro: who help me to fix
Asked and answered twice.