Check if Pending Order is already Market Order

Back to topics list To post a new topic, please log in or register
avatar
54
WorstCases 2011.11.18 10:43
 

Hello.

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.


Thank you.

WorstCases

 
avatar
14167
avatar
13001
WHRoeder 2011.11.18 14:43 #
 
Ticket number only changes on a partial close.
avatar
54
WorstCases 2011.11.18 23:36 #
 

Thanks guys. This sure was my mistake!


avatar
4
jtdjtd 2013.03.14 11:33 #
 

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

pending to market order, new ticket 

I'm currently using MT4.00 Build 455. 

 
avatar
14167
RaptorUK 2013.03.14 11:56 #
 
jtdjtd:

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?

3.  you can do it either way,  but . . .  if you use ticket how will you do that in the event that MT4 or your PC crashes and you have to pick up from where you left off ?  are you going to save the ticket numbers and related info to a file and read that when MT4 restarts ?

 
avatar
4
jtdjtd 2013.03.14 12:31 #
 
RaptorUK:
3.  you can do it either way,  but . . .  if you use ticket how will you do that in the event that MT4 or your PC crashes and you have to pick up from where you left off ?  are you going to save the ticket numbers and related info to a file and read that when MT4 restarts ?


RaptorUK,

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 

 
avatar
14167
RaptorUK 2013.03.14 13:10 #
 
jtdjtd:


RaptorUK,

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 

Yes,  that seems like a possible solution,  another which involves less work is to find an alternative Broker ;-)

 
avatar
49
gadget 2015.01.27 15:38 #
 

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...


Back to topics list  

To add comments, please log in or register