How to determine why an order closed In MQL 4?

 

There are several reasons why an order was closed:

        Unknown = -1,

        Expiration = 0,

        Market = 1,

        TakeProfit = 2,

        StopLoss = 3,

        Risk = 4


In MQL 4, how does one determine why an order was closed?

How does one determine if an order was closed by Market, Stoploss or TakeProfit?

[Deleted]  
If your order was closed by StopLoss or TakeProfit the order comment will be updated by your broker to start with "sl:..." or "tp:...". If your order was closed because your minimum margin level was reached (margin call) the order comment will be updated by your broker to start with "so:..." which means "stop-out". If the order comment of a closed order is unchanged or empty the order was closed manually, most probably by yourself. So you have to check OrderComment().