mql4mql

MQL4 how can I check if the order hit SL?


I am coding an algorithmic trading robot and how can I check if the order hit SL on MQL4?


Solution

  • The most robust method is to record then track the trade using its OrderTicket(). Track this until the trade is closed (using OrderCloseTime() to determine when closed). You can then retrieve the OrderClosePrice() and check it against the OrderStopLoss().