ok I found it....
https://forum.mql4.com/57347#832266
Finally I don't get what I was expecting:
//////////////// GLOBAL VAR //////////////////////// int GV_TOTAL_ASSET_AUD = GlobalVariableGet("GV_TOTAL_ASSET_AUD"); int GV_TOTAL_ASSET_CAD = GlobalVariableGet("GV_TOTAL_ASSET_CAD"); int GV_TOTAL_ASSET_CHF = GlobalVariableGet("GV_TOTAL_ASSET_CHF"); int GV_TOTAL_ASSET_EUR = GlobalVariableGet("GV_TOTAL_ASSET_EUR"); int GV_TOTAL_ASSET_GBP = GlobalVariableGet("GV_TOTAL_ASSET_GBP"); int GV_TOTAL_ASSET_NZD = GlobalVariableGet("GV_TOTAL_ASSET_NZD"); int GV_TOTAL_ASSET_USD = GlobalVariableGet("GV_TOTAL_ASSET_USD"); int GV_TOTAL_ASSET_JPY = GlobalVariableGet("GV_TOTAL_ASSET_JPY"); //--- //--- //--- https://forum.mql4.com/57347#832266 // lets assume that: int USD_strength = GV_TOTAL_ASSET_USD, GBP_strength = GV_TOTAL_ASSET_GBP, JPY_strength = GV_TOTAL_ASSET_JPY, CHF_strength = GV_TOTAL_ASSET_CHF, EUR_strength = GV_TOTAL_ASSET_EUR, AUD_strength = GV_TOTAL_ASSET_AUD, CAD_strength = GV_TOTAL_ASSET_CAD, NZD_strength = GV_TOTAL_ASSET_NZD; // create and initialize arrays string currencies[] = {"USD", "GBP", "JPY", "CHF", "EUR", "AUD", "CAD", "NZD"}; string currencies1[] = {"USD"}; int num_array[8][2]; ArrayInitialize(num_array, 0); // put data in num_array and sort // * as you can see, num_array[x][1] holds the index for the appropriate currency in currencies[] num_array[0][0] = USD_strength; num_array[0][1] = 0; num_array[1][0] = GBP_strength; num_array[1][1] = 1; num_array[2][0] = JPY_strength; num_array[2][1] = 2; num_array[3][0] = CHF_strength; num_array[3][1] = 3; num_array[4][0] = EUR_strength; num_array[4][1] = 4; num_array[5][0] = AUD_strength; num_array[5][1] = 5; num_array[6][0] = CAD_strength; num_array[6][1] = 6; num_array[7][0] = NZD_strength; num_array[7][1] = 7; string text = "Unsorted: "; /* for (int j = 0; j < ArrayRange(num_array, 0); j++) text = text + currencies[num_array[j][1]] + " = " + num_array[j][0] + ", "; text = StringSubstr(text, 0, StringLen(text)-2); //removing last comma // Print (text); ArraySort(num_array); text = "Sorted (ascending): "; for (j = 0; j < ArrayRange(num_array, 0); j++) text = text + currencies[num_array[j][1]] + " = " + num_array[j][0] + ", "; text = StringSubstr(text, 0, StringLen(text)-2); //removing last comma //Print (text); */ ArraySort(num_array, WHOLE_ARRAY, 0, MODE_DESCEND); text = "Sorted (decending): "; for (int j = 0; j < ArrayRange(num_array, 0); j++) text = text + currencies[num_array[j][1]] + " = " + num_array[j][0] + ", "; text = StringSubstr(text, 0, StringLen(text)-2); //removing last comma Print (text);
I would like to get this in case
int GV_TOTAL_ASSET_USD = 20; int GV_TOTAL_ASSET_AUD = 16; int GV_TOTAL_ASSET_EUR = 10; int GV_TOTAL_ASSET_NZD = 8; int GV_TOTAL_ASSET_CAD = 6; int GV_TOTAL_ASSET_CHF = 0; int GV_TOTAL_ASSET_JPY = -5; int GV_TOTAL_ASSET_GBP = -13;
Rank_USD_strength = 1; // First (strongest) Rank_AUD_strength = 2; Rank_EUR_strength = 3; Rank_NZD_strength = 4; Rank_CAD_strength = 5; Rank_CHF_strength = 6; Rank_JPY_strength = 7; Rank_GBP_strength = 8; // Last one (weakest)
Please help
Cheers
Baptiste George:
Finally I don't get what I was expecting:
I would like to get this in case
Please help
Cheers
I've found this quite interesting but unfortunately have no idea on how to make this.
Baptiste George:
Finally I don't get what I was expecting:...
The code looks ok. What's the issue with it?
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
Hi all
I would like to sort 8 global variables that are constantly updated.
I have read ArraySort() fuction... but I can't figure it out.
Please help
Cheers