shall I know an order has been closed at once?

 

when I open an order some time, but some time the order had been closed at stop loss, shall I know it immediately when the order is closed at once by EA and send an reverse order?

is there some function to do this?

if not, how I should set to achieve this target?

in the fact, I have make codes to do this, by orderselect(ordershistorytotal()-1, select_by_pos, mode_history), but most time the reverse order has been sent after many bars.

 
vx0532:

when I open an order some time, but some time the order had been closed at stop loss, shall I know it immediately when the order is closed at once by EA and send an reverse order?

is there some function to do this?

if not, how I should set to achieve this target?

in the fact, I have make codes to do this, by orderselect(ordershistorytotal()-1, select_by_pos, mode_history), but most time the reverse order has been sent after many bars.

I do something similar to take Screen grabs of newly closed trades, I keep track of the last trade a Screen grab was created for, I check for trades with OrderCloseTimes() newer than the last one Grabbed and when I find a newer closed trade I take a new Grab. This code is executed outside of any "once per bar" code so it can happen more frequently.
 

ok

Thanks a lot!