Did it hit the SL?

 

Can anyone tell me if it's possible to run through my trade history, using MQL, to find out if a specific trade was stopped out?

I have a few techniques to close trades, but I would like to know if there is a variable that stores whether the reason it closed was because of the SL.

Thanks

Johnny

 
JohnnyInamoto:

Can anyone tell me if it's possible to run through my trade history, using MQL, to find out if a specific trade was stopped out?

... but I would like to know if there is a variable that stores whether the reason it closed was because of the SL.

Just loop through the order history and compare the OrderClosePrice() to the OrderStopLoss().

  • if the order was an OP_BUY and the OrderClosePrice <= OrderStopLoss, the buy order was stopped out.
  • if the order was an OP_SELL and the OrderClosePrice >= OrderStopLoss, the sell order was stopped out.

 

The term stop-out is a margin call.

OrderClosePrice <= OrderStopLoss means the buy was closed by the stop loss.

 
Thanks chaps :)
Reason: