ea was interrupted, pls help!

 

dear community!

the problem: i have an ea running, o.k. so far, suddenly the pc shut down and restarted, so the ea started also new, when the everything was online and running again.

now my problem: i have opened orders and my ea does not recognise them anymore. in my ea i use the "SELECT BY TICKET" function to identify an order, but as long as i understand it now, it does only work when the ea runs without any interruptions. what function should i use to identify open orders in case the ea has to restart ?

thank you so much in advance,

best regards

oliver

 
i suggest to identify trough the magic number, of if thats not enough a combination of magic number and comment
 
zzuegg:
i suggest to identify trough the magic number, of if thats not enough a combination of magic number and comment


hi zzuegg!

thank u for ur reply!

so u mean, when i open an order i shall link it with the magicnumber, and i can find the order again under any circumstances?

greetings

oliver

 

afaik yes.

you have to interate trough all your open orders, with

for(i = OrdersTotal()-1;i>=0;i--){
  OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
  if( OrderMagicNumber()==magicOfEA && OrderSymbol()==Symbol() ){
  
  }
}
 

Or.. your EA could recover the list of open tickets by using

https://docs.mql4.com/trading/OrderTicket

on init()

Then carrying on as before...?

-BB-

 

but without magic numbers, and i assume you have 2 or more EA's running how could you identify the right orders in the init() ?

possible is also storing the current open order tickets in a textfile, but for me identifing the orders with magic numbers is the shortest implementations...

but i am always open to better way's..