Download MetaTrader 5

Problem sending trade close confirmation email

To add comments, please log in or register
timothysmith78
33
timothysmith78  

Hi MQL community,

When my EA closes a trade I want it to send me an email confirming if it was a winning or losing trade.

My problem is that it keeps sending multiple emails. I'm not sure if it's a problem with my code or a broader technical issue as

when I send the generic email "test", I sometimes receive multiple copies also. Can someone please help!

Please see journal entries and code below:

 if(OrderSelect(OrderTicket(),SELECT_BY_TICKET,MODE_HISTORY)==true)

 if( OrderMagicNumber() == MagicNumber)
 if(OrderType()==OP_SELL)
 if (OrderClosePrice()>=OrderTakeProfit())
     SendMail("winner","winner");
     else (GetLastError());
 if (OrderClosePrice()<=OrderStopLoss())
     SendMail("loser","loser");
     else (GetLastError());

Regards, Tim

Carl Schreiber
7467
Carl Schreiber  
Use OrderCloseTime() and check whether it is greater than the time of your last email.
To add comments, please log in or register