**
MQL4 Book
Standard Functions
Arrays and Timeseries **

Let's work out some values of the elements and represent the initial and the desired matrices that the Mas_1 and Mas_2 arrays contain respectively:
Fig. 151. Initial and Transposable Matrices. In this case, the problem resolves itself to rewriting the values of the first matrix to the second one according to the rules of matrix transposition, namely rewrite the elements values of the first matrix columns to the rows of the desired matrix. The solution of matrix transposition problem is represented in the matrix.mq4 expert: //-------------------------------------------------------------------- Two arrays are opened in the start() function of the expert. The Mas_1 array has 3 rows containing 5 elements each and the MAS_2 array has 5 rows containing 3 elements each. The rewriting of the values itself is performed in the following entry: Mas_2[[j][i] = Mas_1[i][j]; // Matrix transposition In order to calculate the runtime environment (the number of iterations) of two embedded cycle operators, you should know the values of the elements of each array. In this example the constant values 3 and 5 could be used. However, this way of program designing is incorrect. In general, a program can contain a huge code wherein the calling to the same values is performed in many parts of it. A program must be designed so that the modifications could be made in one place, if necessary, and in all the other necessary parts they would be calculated. In this case, only the entries that open and initialize the arrays should be modified if it is necessary to change the size of the arrays, so there is no need to modify the code in the other parts. To determine the number of elements of the first and second dimensions of the Mas_1 array the following calculations are performed: int R0 = ArrayRange( Mas_1, 0); // Number of elements in first dim. Note that the 0 value is used for the first dimension and the 1 value is used for the second one. The calculated values of the R0 and R1 variables are used to determine the number of iterations in the "for" cycles. The received values of the Mas_2 array elements are displayed on the screen using the Comment() function.
## Functions for Working with Arrays
## Functions to Access Timeseries
To get the detailed information about these and other functions, please refer to the Documentation at MQL4.community, at MetaQuotes Ltd. website or at the "Help" section of MetaEditor. |