Alert() question

 

I added this alert to a code. I'd like to get only one alert when a line reach an other line. But when lines meet I get alert every price moving.


How can I avoid this?



if (n_max==ExtMapBuffer0[cnt])


Alert("Open_Sell: ",Symbol()," M",Period());


Thx.

 
static AlreadyAlertedFlag = false;

if (n_max==ExtMapBuffer0[cnt] && AlreadyAlertedFlag == false){
   Alert("Open_Sell: ",Symbol()," M",Period());
   AlreadyAlertedFlag = true;
}




 
phy:

Thanx a lot phy.

 

Hello! I would really need your help. Here is my problem. In code bellow I get arrow only once (that is OK I want it only once) but alert goes on 3 times (3 candles). Why do I still get alerts even if conditions are not true? I get alert when +DI crosses -DI, but then I get alert again in next candle even there is no +DI and -DI cross.

Thanks!

for(int i = limit - 1; i >= 0; i--){         
   adx = iADX(NULL, Period(), 14, PRICE_CLOSE, MODE_MAIN,i);
   plus = iADX(NULL, Period(), 14, PRICE_CLOSE, MODE_PLUSDI,i+1);
   minus = iADX(NULL, Period(), 14, PRICE_CLOSE, MODE_MINUSDI,i+1);
   plus_pred = iADX(NULL, Period(), 14, PRICE_CLOSE, MODE_PLUSDI,i+2);
   minus_pred= iADX(NULL, Period(), 14, PRICE_CLOSE, MODE_MINUSDI,i+2);

   if(adx>ADX_current && plus_pred>minus_pred && plus<minus){
      bearish[i+1] = High[i+1] + Range*1;//       SELL            
      if (Alerts_ON_OFF && alertTag!=Time[0]){   
         Alert("Sell ",Symbol(),"! DI and ADX conditions met at ",Frame,".");
         alertTag=Time[0];
      }
   }
         
   if(adx>ADX_current && plus_pred<minus_pred && plus>minus){
      bullish[i+1] =  Low[i+1] - Range*1;//      BUY   
      if (Alerts_ON_OFF && alertTag!=Time[0]){   
         Alert("Buy ",Symbol(),"! DI and ADX conditions met at ",Frame,".");
         alertTag=Time[0];
      }
   }
}
 
01005379:

Hello! I would really need your help. Here is my problem. In code bellow I get arrow only once (that is OK I want it only once) but alert goes on 3 times (3 candles). Why do I still get alerts even if conditions are not true? I get alert when +DI crosses -DI, but then I get alert again in next candle even there is no +DI and -DI cross.

Thanks!


Anyone, please!
 
alertTag=Time[0];
must be global or static. No mind readers here, post all the relevant code.