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.
- ArrayCopy (only if each array is exactly the same size)
- 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; } }
- Avoid the problem. Just pass the arrays to a function:
yourFunction(array1, array2); : yourFunction(array2, array1); // swapped
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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.