questions about the use of Array
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
For example, I will create the variable dollar, euro, franc, etc., and then declare the largest one based on the value as the strongest and the smallest value based on the value as the weakest.
In PHP, you can give a key and a value for each element of the array. Is it possible to do the same in MQL4 ? Thanks
Not as straight forward as PHP, but some things you could consider are:
int inArray[3] = {}; //Method 1 - constants #define d_USD 0 #define d_NZD 1 #define d_CHF 2 inArray[d_USD] = 59; inArray[d_NZD] = 48; inArray[d_CHF] = 70; ArrayPrint(inArray); PrintFormat("d_USD = %d", inArray[d_USD]); PrintFormat("d_NZD = %d", inArray[d_NZD]); PrintFormat("d_CHF = %d", inArray[d_CHF]); //Method 2 - enum enum { e_USD = 0, e_NZD = 1, e_CHF = 2 }; PrintFormat("e_USD = %d", inArray[e_USD]); PrintFormat("e_NZD = %d", inArray[e_NZD]); PrintFormat("e_CHF = %d", inArray[e_CHF]);
PS - I use MQL5 so check it works for MQL4
I would create a separate array of symbols:
string symbols[]={"GOLD","AUDCAD.r"......}
And then calculate a separate array of scores and the symbol index.
double pairs[28][2]; for(int i=0;i<ArraySize(symbols);i++){ pairs[i][0]=50 // score pairs[i][1]=i; // symbol array index }
Then you can sort pairs array by score to get the strongest to weakest. ==> ArraySort(...)
For example, I will create the variable dollar, euro, franc, etc., and then declare the largest one based on the value as the strongest and the smallest value based on the value as the weakest.
In PHP, you can give a key and a value for each element of the array. Is it possible to do the same in MQL4 ? Thanks