Send market order but get a pending order?!

 

Hey,

new issue. I send a market order and try to read the data immediately after the order has been sent - in synchronous mode - not async. So I use PositionSelect() afterwards, using the ticket number which is returned but get return value false. But when I use OrderSelect() instead, MT5 shows me that there is a pending order. Did I miss something?

When I debug the code, step by step, I works fine, but not when I simply let it execute without interrupting.

Is this normal behaviour? For my understanding, this should be like that only when dealing with asynchronous processing.

Thanx in advance.

 
When I insert a Sleep(100) in between, it works as it should.
 
Doerk Hilger:

Hey,

new issue. I send a market order and try to read the data immediately after the order has been sent - in synchronous mode - not async. So I use PositionSelect() afterwards, using the ticket number which is returned but get return value false. But when I use OrderSelect() instead, MT5 shows me that there is a pending order. Did I miss something?

When I debug the code, step by step, I works fine, but not when I simply let it execute without interrupting.

Is this normal behaviour? For my understanding, this should be like that only when dealing with asynchronous processing.

Thanx in advance.

This is the right behavior.

 
fxsaber:

This is the right behavior.

Never recognized this, weird. Thank you ... and of course I used Google etc., but probably the wrong search options. 

 
Doerk Hilger:

Never recognized this, weird. Thank you ... and of course I used Google etc., but probably the wrong search options. 

I confirm fxsaber answer, it's how MT5 works. There was a lot of topics along the years from people surprised about this (including me at the beginning).
 
At the moment there is only one library that bypasses these features of the platform architecture.
 
fxsaber:
At the moment there is only one library that bypasses these features of the platform architecture.

Now it´s two ;) 

 
Doerk Hilger:

Now it´s two ;) 

I would like to try.

 
fxsaber:
At the moment there is only one library that bypasses these features of the platform architecture.
The others are private.
Reason: