Looking when pending order is started and when tp/sl was triggered

 

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?

 
See this topic and follow the links.
OnTakeProfit & OnStopLoss instead of OnTradeTransaction()
OnTakeProfit & OnStopLoss instead of OnTradeTransaction()
  • 2016.02.18
  • www.mql5.com
OnTakeProfit & OnStopLoss instead of OnTradeTransaction().
 

Hello Alain,


thanks you for your support.