How to invert two arrays in mql4 ?

 

I want to invert two arrays in EA. Can you suggest me any code ?

For example, I've array1[x][y] and array2[x][y]. I want to get all contents of array2 in array1 and contents of array1 in array2.

 
Add array3,  use ArrayCopy() to copy from array2 -> array3  then array1 -> array2  finally array3 -> array1
 
The word is swap arrays. Inverting an array is a mathematical computation.
  1. ArrayCopy (only if each array is exactly the same size)
  2. switch the elements
    void swapArrayElements(double& array1[][], double& array2[][]){
       int nRows = ArrayRange(array1,0), nCols = ArrayRange(array1,1);
       for(int iRow = 0; iRow < nRows; iRow++)
          for(int iCol = 0; iCol < nCols; iCol++){
              double tmp         = array1[iRow][iCol];
              array1[iRow][iCol] = array2[iRow][iCol];
              array2[iRow][iCol] = tmp;
          }
    }

  3. Avoid the problem. Just pass the arrays to a function:
    yourFunction(array1, array2);
    :
    yourFunction(array2, array1); // swapped

Reason: