Codeing Partial Close in MT4 - Problem OrderticketNumber change

 

Hello,

i wanted to code a partial close and i wanted to use the order ticket number to let my program remember that he have done a partial close for a order already, but i see now a problem, the orderticket number does change when i make a partial close on a open order. Does somebody know what i can else use instead of the orderticket number?

 
 
PlanandTrade: instead of the orderticket number?
If the power fails, OS crashes, terminal or chart is accidentally closed, the next tick, the ticket variable will be 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 no recovery, or persistent storage (GV/file) of ticket numbers required.
 
i did that by adding 1 point to the stoploss each time it was partially closed
 
PlanandTrade:

Hello,

i wanted to code a partial close and i wanted to use the order ticket number to let my program remember that he have done a partial close for a order already, but i see now a problem, the orderticket number does change when i make a partial close on a open order. Does somebody know what i can else use instead of the orderticket number?


You might review and tweak some code (build 509) that I posted about a year ago. The PartialOrderClose() builds a list of all open orders, performs the partial OrderClose(), and then determines which order is new by comparing all open trades to the list it previously built. Upon finding the new order, PartialOrderClose() returns the ticket number for the new order. As the code suggests, it would probably be helpful to use a magic number to a particular EA (or to a set of trades).