When looking at the OrderSend function documentation, i notice that it will return an int with the order number.
But I'm actually curious to how this is done. When you send an order no order id is known initially, how does the function know what ID is being corresponded to the function call?
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Did you not read the documentation you referenced? ... OrderSend - Trade Functions - MQL4 Reference
What does it state about the return value?
Returned value
Returns number of the ticket assigned to the order by the trade server or -1 if it fails. To get additional error information, one has to call the GetLastError() function.
The function sends the request to the broker's trade server, which then sends back the ticket for it. It is a synchronous function which blocks any further execution for a certain amount of time, while it waits for the response.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
When looking at the OrderSend function documentation, i notice that it will return an int with the order number.
But I'm actually curious to how this is done. When you send an order no order id is known initially, how does the function know what ID is being corresponded to the function call?