I determinated my EA to open a position with volume = 1.0
Sometimes he will do that, sometimes he add a second order, so that the volume is 2.0
Did anyone had the same problem ?
Maybe I have a mistake in my code, but with MQL4 I have not this problem.
Yes, I have had the same issue. OrderSend can return control to the EA before the position size has changed. So if you query position size immediately after an OrderSend, it may not indicate the change. I think this can occur even when the RetCode from the OrderSend is TRADE_RETCODE_DONE.
For the moment, I am using this code to poll for the change in position size as a result of the OrderSend.
Print("PositionChangeSizeAtServer() error: Problem with OrderSend, return code "+RetCodeToStr(MtResult.retcode));
Print("PositionChangeSizeAtServer() result of OrderSend to server: "+RetCodeToStr(MtResult.retcode));
while(OpenLots()==nCurrentLots && nRepeatCount>0)
Print("PositionChangeSizeAtServer() retrying #"+(string)nRepeatCount);
Print("PositionChangeSizeAtServer() error: Order failed to complete after "+(string)nRepeatCount+" seconds");
This function returns +/- position volume*1000 for the above code
Print("Problem with POSITION_TYPE in OpenLots()");
At the moment if I want to open an order with Volumen = 1, I set the value to 0.5.
In 80 Percent of the trades the EA opens 2 orders, so the volume is as expected.