Examples of using Trade function in English and their translations into Russian
{-}
-
Official
-
Colloquial
User-Defined Executive Trade Function Open_Ord.
The control trade function Trade() is formed as include file Trade. mqh.
User-Defined Executive Trade Function Close_All.
The executive trade function Open_Ord() is formed as include file Open_Ord. mqh.
User-Defined Executive Trade Function Tral_Stop.
The executive trade function Tral_Stop() is formed as include file Tral_Stop. mqh.
The Competition Commission had handled many cases andhad now been given some trade functions.
Each executive trade function has a special range of tasks.
At the moment t1, the program has formed a trade request as a result of the execution of a trade function.
The executive trade function Close_All() is formed as the include file Close_All. mqh.
The value returned by the function is taken into consideration in the executable trade function of the above EA.
Trade function OrderClose() returns true, if the trade is made successfully, and false, if not.
Errors in all user-defined executive trade functions are processed in a similar way.
On the other hand, trade functions cannot be used in indicators: OrderSend(), OrderClose(), OrderCloseBy(), OrderDelete() and OrderModify.
A request made by the program as a result of the execution of a trade function is passed to the client terminal for processing.
The controlling trade function and the function defining trading criteria must be coordinated with each other in the values of the parameters they pass.
In order to see this for ourselves,let's consider the simplest variation of how the trade function OrderSend() is used for opening a market order.
A trading strategy in a normal EA is realized on the basis of two functions- a function defining trading criteria and a control trade function.
For the variant when thegreen line crosses the red one downwards, in'if' body a trade function for opening a Sell order should be indicated.
For example, the function defining trading criteria cannot be called from any special function, butit can be called for execution by a trade function.
If the trade request formed as a result of the execution of one of trade functions has turned out to be incorrect, the control is passed to the program.
All trade functions can be divided into two groups- functions that form trade orders and functions that return some order characterizing values.
Thus, the only possibility to inform the user about the start of events related to the request is to show the message before the assignment operator,in the right part of which the trade function is specified.
If there is enough money, the trade function Open_Ord(0) is called to open one market order Buy with the amount of lots calculated at the execution of function Lot.
The section provides the detailed description of the order of performing trades andcontains a lot of examples that explain the purposes of all trade functions used to form trade orders.
It was said earlier that according to MQL4 rules trade functions cannot be used in custom indicators, that is why for automated trading Expert Advisors or scripts should be used.
The code of the function Trade() is written in such a way that the control is not returnedto the function start() until all required executive trade functions are executed.
If it returns'false',then the trade function stops and the control is sequentially passed to the calling function, then to the start() function, and then to the client terminal.
If it returns'false'(the error is critical), the execution of the function Open_Ord() ends,the control is consecutively passed to the control trade function Trade(), to the special function start() and then to the client terminal.
Before we start to describe trade functions, we should consider parameters that characterize market prices, order types, their characteristics, as well as the rules for making trades. .