OrderSelect and OrderDelete

 

Hi friends,

I've coded an EA that opens and deletes orders based on some situation. I'm saving the ticket number of the placed orders and by new ticks come in, I repeatedly check them for further calculations by using OrderSelect function with their ticket numbers that have been saved previously.

Now I want know how can I find out whether the selected order exists or it's been deleted from the orders book.

I'm not sure do I need to check the OrderCloseTime() of the selected order to see if the order has been deleted or not or I need to check other detail of the deleted orders to find out whether the order is cancelled previously or it exists as a pending order in the orders book.

My main doubt is about OrderCloseTime() function of the deleted orders. is it the same as the closed orders that if the order is deleted then the OrderCloseTime() of the order would be different from 0 ?

Thanking in advance for your kind guidance,

 
parham.trader: I'm saving the ticket number of the placed orders

if the order is deleted then the OrderCloseTime() of the order would be different from 0 ?
  1. EA's must be coded to recover. If the power fails, OS crashes, terminal or chart is accidentally closed, on the next tick, any static/global ticket variables will have been lost. You will have an open order but don't know it, so the EA will never try to close it, trail SL, etc. How are you going to recover? Use a OrderSelect loop to recover, or persistent storage (GV+flush or files) of ticket numbers required.
  2. Yes
 
whroeder1:
  1. Yes

Thank you so much @whroeder1 ,Great response as always !