1. Home > >

Forex Smart Trading MQL4 Language Tutorial (3)

4.2. Instruction structure of MetaQuotes4 language 4.2.1. variable declarations forexcashbackprofitcalculator statements to save temporary data during calculation requires the use of cashback forex profit calculatorVariables are descri cashbackforexprofitcalculatord in the beginning of th cashback forex program with reserved words, variables, cashbackforexpipcalculators and defininesHe allows using negative forms of these words, namely Variables, ArraysandDefines, there is always a declaration of variables in the middle of these words, and the difference between these words is as follows: variable statements are simple variables, array statements are arranged, and define statements attach user-defined variables, similar to predefined user variables, which can be modified through the settings dialog, i.e., externally. However, unlike predefined variables, user variables can be changed during computation within the program: Counter(0); an example of a string variable declaration: Variable:String1(any string); an example of a logical variable declaration: Variable:MyCondition(false); an array declaration syntax: Array:ArrayName[Arraylength](initial value); where array length has one or several (up to 4) numbers-number[,number[,number[,number]]]. In the MetaQuotes4 language, an array may be 1-,2-,3-,4-elements long. In general, an array is a set of variables that can be found by the same name and positioned in successive rows and given the sequence number (number) of the array elements. For example, Close[5] refers to the closing value of the back 5 trading periods. An array of two elements may be a simple table, where the first component is a row and the second component is a column Array:MyTable[10,5](0);// a table of 10 rows and 5 columns... ...print(MyTable[2,4]);//print the fourth element of the second row The array may include any type of value-number, string, or logical value, but should be of the same type, with the initial value declared as a specific additional user-defined variable declaration syntax when the array is declared: definition: name (initial number); where name is the variable name It should be noted that additional user-defined variables may be of numeric type only. As mentioned above, user-defined variables can be modified during the calculation of the program and these modifications can be applied only to the current session of the ITS until the special ITS is removed from the chart or the operation of the client terminal is finished. The exit report interrupts the operation of the ITS software, which is also known as a pre-defined program termination.