Closed position (Push Notification) (Help)

 

Hello,

 I've been trying to fix my indicator which should send me a push notification if my order has hit SL or TP and for some reason every time an order closes I do get a push notification but for all my trades in my history. How do I make it so I only get it for the one that just closed and not the ones that have closed at a previous date? Thanks 

void AlertOrder()

{

   string txt;

   double OCP;

   int i=OrdersHistoryTotal()-1;

   if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true)

   {                                

      OCP=OrderClosePrice();

      if (OCP==OrderStopLoss()) txt="SL";

      if (OCP==OrderTakeProfit()) txt="TP";

      }

      SendNotification(Symbol() + " hit "+txt+"");

 }

 
send it at the moment it is closed, when it is closed.
 
Marco vd Heijden:
send it at the moment it is closed, when it is closed.
How?
 

ah i see you are server dependant i was thinking your robot ordered to close , but it is a lever that is hit, then you can simply

check the notify of trade transactions function in settings.


Reason: