Closed position (Push Notification) (Help)
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?
send it at the moment it is closed, when it is closed.

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+"");
}