Hi guys. I'm a little stunned with this problem and I can't seem to get around it... Let's say I have a calculation where I want to maintain the contents of an array to check if they are still valid. I run trough the original array, while comparing the contents to a criteria. If a content is no longer valid, I leave it. If the content is valid, I put it to a temporary array, and so on. In the end of the day, this temporary array, called TempIndexes should replace the array called OpenIndexes. So in the end of the calculation I do this: int OpenIndexes[34]; // ***** REST OF PROGRAM *** void MaintainIndexes() { int TempIndexes[34]; // ***** CALCULATION TO MAINTAIN INDEXES *** OpenIndexes=TempIndexes; // ** THIS DOESNT WORK return 0; } Does MQL4 allow this kind of replacement of variables?
- What is the correct way to fill an array with Positions?
- Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes
- Questions from Beginners MQL4 MT4 MetaTrader 4
I'm sorry I don't know why my posts sometimes get screwed up like this... :(
If you dont want to change the type of array, the original(first) and temporary have to be same type (ex.: "double doubleArray[nn];" same as "double doubleTemp[nn];")
If copy from "int Temp[nn]" to "double Original[nn]", decimals does not exist later in original.
You can use standard mql4 ArrayCopy or if you have customArray[NN][nnFixed] you have to make loop listing from 0 to ArraySize()-1,
if additional 2-nd dimension is present, inside loop - another loop for the structure to maintain update to all arrays data.
If copy from "int Temp[nn]" to "double Original[nn]", decimals does not exist later in original.
You can use standard mql4 ArrayCopy or if you have customArray[NN][nnFixed] you have to make loop listing from 0 to ArraySize()-1,
if additional 2-nd dimension is present, inside loop - another loop for the structure to maintain update to all arrays data.
// 2 dimensianal array update for(int i=0; i<ArraySize(original)-1; i++) { for(int j=0; j<34-1; j++) original[i][j] = temporary[i][j]; } // update done
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