Download MetaTrader 5
To add comments, please log in or register
Install apps from the library right in MetaTrader. It is easy!
Luis
226
Luis 2015.01.07 11:33 

How to differientate if a position has been closed by an user manually or by the EA logic?

Is this possible?

Greetings

BeLikewater

Carl Schreiber
5967
Carl Schreiber 2015.01.07 12:36  

1) the EA has to save the ticket number

2) the EA to delete this ticket number in case the EA closes it.

3) If this ticket number 'disappers' (OrdersTotal()) or OrderClose() creates an Error (most probable):

4108

ERR_INVALID_TICKET

Invalid ticket


you the EA should know it has been closed by someone or something  (STP,TGT) else.

whroeder1
13656
whroeder1 2015.01.07 12:55  
gooly: If this ticket number 'disappers'

4108

ERR_INVALID_TICKET

Invalid ticket

Ticket numbers never disappear, they only move from active list to the history list. If a pending order is deleted, or an open order is closed (by what ever reason) it is in the history list. If you select by valid ticket you will get the order.

BeLikeWater: How to differientate if a position has been closed by an user manually or by the EA logic?
There is no way to tell. As gooly implied, only the EA knows it is about to close a position. It must remember that fact in persistent storage (disk.) either (short term) a Global (terminal) Variable with the name including the ticket number, or (long term) a file.
chudanever
232
chudanever 2015.01.07 19:15  
i think magic no can go.just put magic no on your close order identifier
Luis
226
Luis 2015.01.07 19:53  

So its no possible.. I think it should be implemented, could have its functionality!

Greetings

BeLikewater

/
To add comments, please log in or register