Can somebody please explain what code I need to check if a pending order with known ticket# is still pending or already open (market order)?
As far as I know the ticket# changes when pending becomes market.
Thanks guys. This sure was my mistake!
Hello, waking up an old post..
It appears to me that my MT4 broker, Oanda, does in fact create a new ticket when a pending order becomes a market order (both when I manually enter a pending order through MT4 and when an EA enters a pending order). My EAs are not written for this and thus don't work properly with Limit/Stop orders IF a new ticket is created. E.g., my current EAs will attempt to modify SL/TP on closed pending orders because they don't know the new ticket number or how to find it.
1 - Can anyone confirm or deny that Oanda creates a new ticket when a pending order becomes a market order?
2 - If YES, does anyone have any simple suggestions for how to overcome this obstacle? I would appreciate avoiding substantial revisions to all my EAs wherever pending orders are wanted.
3 - Is it generally accepted practice to use OrderSelect() by index (SELECT_BY_POS) (rather than ticket (SELECT_BY_TICKET)) to keep track of/manage orders and should I have been using this all along?
Thanks in advance for any help or feedback. I've also attached a screenshot of my "Trade Terminal > Account History" so you can see what I think are new tickets generated by my broker. JTD
I'm currently using MT4.00 Build 455.
Thanks for your speedy reply and your many contributions to these forums.
A - I do pass arrays of information including ticket numbers to files and ask init() to reload those tickets.
2. - Assuming I have to deal with different tickets for pending-to-market orders.. maybe the simplest changes I can make are to figure out how to scan the index of open orders (SELECT_BY_POS, MODE_TRADES) and find one with similar characteristics (buy/sell, lots, SL/TP) to my pending ticket.
Thanks again, JTD
That's a very old thread, but as I've been digging into the problem recently, just to update with a more accurate response on it which might be useful for others.
Oanda does generate a ticket number for each transaction, not for each order. You need to open the web transactions tool to have a complete view, instead of watching the MT4 account history. If you create a pending order let's say a Buy Stop order, and its conditions are realised later, then you would find 3 transactions:
1) Buy Stop Order
2) Buy Stop Filled
3) Std Stop Order Filled
3 important columns: Ticket, MT4 ID, Transaction link.
Transaction 3) will relate to transaction 1) by the Transaction link.
So, in the above functional case, when you know that you have to modify an order, provided you allow only 1 pending or opened for one security, then you should search for it in either the opened orders or in the history, and the unique criteria could be symbol / magic number + order type...
To add comments, please log in or register