How to work correctly in MT5 with OrderSend - page 4

 
fxsaber:
Unfortunately, only through a crutch - a global variable of the terminal.

And through additional crutches to ensure that the main variable is deleted in case of a crash, for example.

So my variant with waiting for a transaction in the history is more reliable and simpler. But it's still a crutch.

 

I haven't checked, but maybe after OrderSend ALL EAs get corresponding event forOnTradeTransaction.

Then everything is solved without crutches and for multiple EAs on the same symbol.

 
prostotrader:

Do you want me to help you bypass these mishaps (from personal experience of trading with MT5 robots on a real account)?

Added

Totally free :)

Want it! :)
 
prostotrader:
People don't want to think for themselves, they want others to do it for them... Unfortunately, this is true.
To think, you have to have information to think about. How can you think if there is not enough background information?
 
fxsaber:

People not only think, but also share their solutions. The developers are silent on this, unfortunately.

Not a single example in the Documentation on this topic. And that's with the main function.

I support. If it was written somewhere that OrderSend() waits for a response from the server and what happens next, there would be no need to come up with workarounds to check.

There is an excellent article about orders, deals and positions and working with them and their cache which details everything. However, it completely sidesteps the processes that take place when orders are sent itself.

 
fxsaber:
My suggestion

prostotrader:

Use it.

What happens if the OnTrade() event is triggered before the OnTick() processing has finished. Sometimes time is of the essence. Waiting until it reaches OnTrade() may be problematic. Besides, the OrderSend() function itself is designed so that I can get information about its results right on the spot. Or is it not?
 
Oleg Shenker:
And what happens if OnTrade() event is triggered before OnTick() processing is finished. Sometimes time is of the essence. Waiting for the OnTrade() event to occur may be problematic. Besides, the OrderSend() function itself is designed so that I can get information about its results right on the spot. Or is it not?

OrderSend() is an absolutely synchronous function - if a ticket is received, everything is executed.

Below is an example

Added, and here are the logs

https://www.mql5.com/ru/forum/38456/page85#comment_2888263

ФОРТС. Вопросы по исполнению
ФОРТС. Вопросы по исполнению
  • www.mql5.com
С большими проблемами удалось это сделать (начальник отдела по работе с профессиональными клиентами ДЦ Открытие Евгений Сергеевич,.
Files:
TestOrders.mq5  23 kb
 
Andrey Khatimlianskii:
Not executed, but sent to the MT5 server.

No. For the Exchange - went to the Exchange (may not have fulfilled :) ), for FOREX I don't know

Added

Ie (for the exchange), if you get a ticket in the OrderSend(() function, it means that the order is accepted by the exchange

Added

See picture (there were changes in 1375)

 
Andrey Khatimlianskii:

This is a special case of sending a limit order to an exchange. What about a market order in forex?

I said I don't know about FOREX
 
Andrey Khatimlianskii:

Not once in this thread. Only about MT5 and OrderSend synchronicity.

So the answer doesn't fit.

No. For Exchange - went to Exchange (maybe not fulfilled :) ), for FOREX I don't know

Added

Ie (for the exchange), if you get a ticket inthe OrderSend(() function, it means that the order is accepted by the exchange

Added

See picture (there were changes in 1375)