[in] Pointer to a structure of MqlTradeRequest type describing the trade activity of the client.
[in,out] Pointer to a structure of MqlTradeResult type describing the result of trade operation in case of a successful completion (if true is returned).
In case of a successful basic check of structures (index checking) returns true. However, this is not a sign of successful execution of a trade operation. For a more detailed description of the function execution result, analyze the fields of result structure.
The trade requests go through several stages of checking on a trade server. First of all, it checks if all the required fields of the request parameter are filled out correctly. If there are no errors, the server accepts the order for further processing. If the order is successfully accepted by the trade server, the OrderSend() function returns true.
It is recommended to check the request before sending it to a trade server. To check requests, use the OrderCheck() function. It checks if there are enough funds to execute the trade operation, and returns many useful parameters in the results of trade request checking:
•return code containing information about errors in the checked request;
•balance value that will appear after the trade operation is executed;
•equity value that will appear after the trade operation is executed;
•floating point value that will appear after the trade operation is executed;
•margin required for the trade operation;
•amount of free equity that will remain after the execution of the trade operation;
•the margin level that will be set after the trade operation is executed;
•comment to the reply code, error description.
It should be noted that the successful completion of the OrderSend() method operation does not always mean a successful deal completion when placing a market order. Check the retcode value containing trade server return code, and values of deal or order field depending on the type of operation in the returned result.
Each accepted order is stored on the trade server awaiting processing until one of the conditions for its execution occurs:
•appearance of an opposite request,
•order execution when the execution price appears,
•a request to cancel the order is received.
The result of executing the trade request on a server sent by OrderSend() function can be tracked by OnTradeTransaction handler. It should be noted that OnTradeTransaction handler will be called several times when executing one trade request.
For example, when sending a market buy order, it is handled, an appropriate buy order is created for the account, the order is then executed and removed from the list of the open ones, then it is added to the orders history, an appropriate deal is added to the history and a new position is created. OnTradeTransaction function will be called for each of these events.