Spam notifications from MT5

 

Every time i get a notification of a trade being triggered, i get like 10 notifications of the same thing, any fix ?


10 Notifications of the same trade:

10 notifications of the same trade

 
Yes this is because when any alert function is triggered, it needs logic to stop it from alerting on every new tick directly after it alerted
 
Conor Mcnamara #:
Yes this is because when any alert function is triggered, it needs logic to stop it from alerting on every new tick directly after it alerted
Is there a way I can limit the notifications to just 1 ?
 

There are multiple ways around it.

my lazy way is to use a state mechanism:

static int alertState = 0;

if(alertState != 1){

  SendNotification("alert");

  alertState = 1;
}


You can also do it this way, make a rule to trigger once in the bar:

static datetime lastAlertTime = 0;

datetime barOpenTime = iTime(_Symbol, _Period, 0);  

if (lastAlertTime != barOpenTime) 
{
    SendNotification("alert");
    lastAlertTime = barOpenTime;
}


then there are more ways (for example to make a recurring alert) based on modulus and the number of seconds in the timeframe (PeriodSeconds)


Is it your EA? If it is not your EA, you need to get in contact with the developer and suggest this code