What happens when stop loss operates

 
Hello, how should I make my EA aware that a stop loss has occurred please? At the moment, when this happens, a lot of errors occur because the program doesn't know the position has been closed automatically. Thank you.
 

when orders hit stoploss, then orders closed with comment: [sl]

 
Yes I realise that but how do I make the EA aware of the order being closed by the stop loss?
 
it's a good question buddy by the way you talk about mql4 or mql5?
 
Sneck55:
Yes I realise that but how do I make the EA aware of the order being closed by the stop loss?

There's a  number of different ways you can do it and it's really going to depend on the logic of your code and also if it's mql4 or 5. Some quick suggestions:

  • Don't set a hard stop (order SL). Control the stop in your code
  • Hold open order tickets in a variable (struct, array etc) then check to see if they're still open
  • Select and analyze closed orders from the pool using MODE_HISTORY
  • And more....

Hope that gets you started

Cheers 

Reason: