Why am I getting multiple alerts instead of one?

 

Hi, I have the following

int Orders;

if(OrdersTotal()<Orders) {

SendNotification("\nOrder Closed\n" + "Open Orders: " + OrdersTotal() + "\nEquity: " + DoubleToStr(AccountEquity(),2) + "\nMax " + Symbol() + " Lots: " + DoubleToStr(maxlots,2));

Alert("Order Closed");

}

Orders = OrdersTotal();

It sends the notification and pops up the alert each time an order closes, but sometimes it sends more than one notification and pops up more than one alert.. they are just seconds apart, but maybe as many as 3 or 4 of each will happen instead of just 1. Any way to get this to stop?

Thank you.

Files:
 
Read the forum, do a search. A LOT of others had similar problems, found many solutions. Isn't it easier to learn from others than to start a new topic? (This is to everyone having multiple alert problems. Your topics are flooding the forum).
 

I have looked and didn't find my answer. If anyone else feels like helping I would appreciate it. Thanks

Even the one posted here seems to repeat it.. I just got 3 alerts for one order close:

https://www.mql5.com/en/code/9642

 
bunnycat:
I have looked and didn't find my answer. If anyone else feels like helping I would appreciate it. Thanks

   if (Orders>OrdersTotal()) AlertOrder();
   if (Orders<OrdersTotal()) SendNotification("Order Closed\n" + "Open Orders: " + OrdersTotal() + "\nEquity: " + AccountEquity() + "\nMax Lots: " + maxlots);

If Orders < OrdersTotal() then you have opened at least one more Order than the last time start() ran . . . so why do you send a notification saying Order Closed ?