Download MetaTrader 5

OrderSelect() does not select order that was just placed

To add comments, please log in or register
Forex Trader
114280
Forex Trader  
Hello, I have a problem.

My EA places an order, then selects the order to get some information about it. It does this fine. Later (in the same cycle) the code will try to do something else with the order. It will execute the OrderSelect() again on the same order (because sometimes it may not already be selected).

The OrderSelect() is failing. It seems to fail if the order was already previously selected.

Can anyone verify if the following is true (maybe a bug?):

res=OrderSelect(myTicket,SELECT_BY_TICKET,MODE_TRADES);
// res==true
res=OrderSelect(myTicket,SELECT_BY_TICKET,MODE_TRADES);
// res==false



Is this true? Any other suggestions??

Thank you anyone for your feedback.

Forex Trader
114280
Forex Trader  
We have the same problem...

Last week Oct 29/30, it was working perfectly but somehow, its no longer works properly last Thursday.
Forex Trader
114280
Forex Trader  
My EA places an order, then selects the order to get some information about it. It does this fine. Later (in the same cycle) the code will try to do something else with the order. It will execute the OrderSelect() again on the same order (because sometimes it may not already be selected).

The OrderSelect() is failing. It seems to fail if the order was already previously selected.

Can anyone verify if the following is true (maybe a bug?):

res=OrderSelect(myTicket,SELECT_BY_TICKET,MODE_TRADES);
// res==true
res=OrderSelect(myTicket,SELECT_BY_TICKET,MODE_TRADES);
// res==false



Is this true? Any other suggestions??



Two consequitive calls to OrderSelect() work just fine.

Try
res = OrderSelect(myTicket, SELECT_BY_TICKET);
Print(res, " ", myTicket);

to make sure that you are selecting the same myTicket.

Forex Trader
114280
Forex Trader  
Thanks for your reply, but I have verified that the ticket number is correct by printing out information.

The OrderSelect() command is in a for() loop that selects a series of trades and changes the limit of each one. It fails to select ticket #200 (the order that was just placed and actually already selected in a prior function), but then it successfully selects tickets #199, #198, #197, #196. Each time it prints the ticket number of the successful or failed OrderSelect(), so I know it is not a ticket number problem.

Anybody else have any ideas? Thanks again.
Hao-Wei Lee
1881
Hao-Wei Lee  

look in official example code : MACD Sample.mq4


if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))

continue;


somehow it just happen on my back-testing until i saw the example code

To add comments, please log in or register