See this topic and follow the links.

OnTakeProfit & OnStopLoss instead of OnTradeTransaction()
- 2016.02.18
- www.mql5.com
OnTakeProfit & OnStopLoss instead of OnTradeTransaction().
Hello Alain,
thanks you for your support.

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
Hi!
I'm developing an EA that works with pending orders. These pending orders get their stop loss and take profit at the start. I need to be able to know if the order has started and if either the stop loss or take profit have been triggered.
The first necessity is easy: I just call HistoryOrderSelect and with HistoryOrderGetInteger I check if the order has the state "ORDER_STATE_FILLED". But I'm having difficulty finding the proper way to do the second request. I know I can use PositionSelect if there is an ongoing operation, but I'd like to avoid such method due to future plans for the EA. I also know I can simply check, tick by tick if the current candle's high and low have crossed either the stop loss or take profit prices, but I'm not sure if that is a guaranteed solution, it looks processor expensive and truly isn't a case of "beautiful" code.
So is there another way of knowing if the operation is still open or if either stop loss or take profit have been triggered?