Your topic has been moved to the section: MQL4 and MetaTrader 4
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Shahriar Soltani:
Hi everyone
In the expert that I want to write, I need to measure the strength of each currency based on a series of parameters and then determine the strongest and weakest currency.
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(...)
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
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