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.
- MetaTrader 5 Automations
- MQL5 Wizard: Development of trading robots for MetaTrader 5
- How to copy deals of successful traders in MetaTrader 5
when orders hit stoploss, then orders closed with comment: [sl]
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?
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
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register