How can I check if a position was closed by the stoploss?

 
Hello guys,

I want to make an expert which checks if a position was closed by the stoploss. As soon as a position is closed by a stoploss I want to be noticed by an Alert. What is the best way to do this? Would you check the order-history with every tick or is it the better way to use OnTrade() or OnTradeTransaction()?

Thank you!
 
Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 

you can try this

void OnTradeTransaction(const MqlTradeTransaction& trans, const MqlTradeRequest& request, const MqlTradeResult& result) 
  {
   if(trans.type == TRADE_TRANSACTION_ORDER_DELETE) // trying to pause trade when SL hit
     {
        Alert("Stop loss hit");
     }
  }