OrderSend is blocking, correct?

 
Hello,

I would just like to confirm that my logic is sound because I have a bug where 2 orders are created when only 1 should be.

in a loop, I check open orders (MODE_TRADES) that the order doesn't exist, then I use OrderSend to create a market order.

OrderSend doesn't return until the order is created (or failure), correct?

I mean, there is no possible way that after OrderSend is called for my first order, that it would not appear in the MODE_TRADES list of open orders before OrderSend is called again?



 
ycomp:
Hello,

I would just like to confirm that my logic is sound because I have a bug where 2 orders are created when only 1 should be.

in a loop, I check open orders (MODE_TRADES) that the order doesn't exist, then I use OrderSend to create a market order.

OrderSend doesn't return until the order is created (or failure), correct?

I mean, there is no possible way that after OrderSend is called for my first order, that it would not appear in the MODE_TRADES list of open orders before OrderSend is called again?



Correct. There's an issue with your check for orders logic.

 

I have a problem understanding the journal though...

the left journal is for the mt4 client that opened only 1 trade on the same instructions from EA

the right journal opened 2 trades on those instructions 

but what confuses me, is shouldn't the right side journal have 2 sell orders? it only shows one... the top messages in the journal are the most recent messages. There is nothing above them and below that you can see that I've only just opened the mt4 clients, these are the first trades of the session

could someone explain why this happens? so I can better troubleshoot my EA


MT4 build:

2019.03.12 01:19:13.507 IC Markets MT4 build 1170 started (International Capital Markets Pty Ltd.)


Here is another example, this time of just one MT4 client running that creates 2 trades

the left side is the journal, the right side is my expert output..

I have only one OrderSend call in my EA.. I put a PrintFormat() statement just before calling it. As you can see, OrderSend was only called once, yet 2 orders appear.

It does not always happen, sometimes only 1 order appears. If I run 3 MT4 terminals with my EA (they will all open trades at the same time), then maybe 1 or 2 of the terminals will have this duplicate trade occurrence.


so I'm not entirely sure what I'm doing wrong since OrderSend was only called once.


could this be a "feature" of this particular broker's demo accounts? I tested it just now with multiple demo terminals of another broker and I'm not encountering this problem there

Reason: