How do I know when an order hits its TAKE PROFIT level inside an EA?

 
Hi all, I would like to be informed when an order hits its SL or TP price specified during the OrderSend (). Which function should I use? Or which method am I called back when it happens? Please advice. Thanks.
 

Loop through order history. Once a trade closes, the count of orders in orders history will increase.

hth

v

   static int LastHistoryCount;
   if (LastHistoryCount!=OrdersHistoryTotal())
      {
      for(int n = LastHistoryCount ; n < OrdersHistoryTotal(); n++)
         {
         OrderSelect(n, SELECT_BY_POS, MODE_HISTORY);
         if (OrderSymbol()==Symbol() && OrderType()<=1 && OrderMagicNumber()==magic)
            {
            // Do stuff
            }  
         }
      }
   LastHistoryCount=OrdersHistoryTotal();
 

And in terms of the "stuff" that you'll do, this may include:

- Assume any in-scope orders which have a +ve return from OrderProfit() have triggered the TP

- Assume any in-scope orders which have a -ve return from OrderProfit() have triggered the SL

- Perform notifications as necessary using SendMail()

CB

Reason: