That won't work - it is only applicable for initialisation.
You could simply it with a multi dimensional array.
string NewsSymbol[][7] = { {"USDJPY","EURUSD","USDCHF","NZDUSD","AUDUSD","USDCAD","USDJPY"}, {"NZDUSD","EURNZD","GBPNZD","NZDCHF","NZDCAD","NZDJPY","NZDAUD"}, {"AUDUSD","EURAUD","GBPAUD","AUDCHF","AUDCAD","AUDJPY","AUDNZD"} };
Hello guys.
Is it possible to change the values of an array after it is defined at the beginning of the program?
for example I have declared an array with default values as follows:
I tried to change all the array values in the program as follows,
but I encountered an error. Can you please help me find out what is wrong with my code?
Thanks
Also, you might want to try using ArrayRemove and then ArrayInitialize to simply rewrite the data.
NewsSymbol
Hello dear ceejay1962 ,
Thank you very much for your good guidance.
Finally it worked. :)//+------------------------------------------------------------------+ //| Variables | //+------------------------------------------------------------------+ enum ENUM_SYMBOL {USD, EUR, GBP , CHF, CAD, JPY , AUD, NZD} ; input ENUM_SYMBOL SYMBOL = USD ; int i = 0 ; string charts[7] = {} ; string NewsSymbol[8][7] = { {"EURUSD","GBPUSD","USDCHF","USDCAD","USDJPY","AUDUSD","NZDUSD"}, {"EURUSD","EURGBP","EURCHF","EURCAD","EURJPY","EURAUD","EURNZD"}, {"GBPUSD","EURGBP","GBPCHF","GBPCAD","GBPJPY","GBPAUD","GBPNZD"}, {"USDCHF","EURCHF","GBPCHF","CADCHF","CHFJPY","CHFAUD","CHFNZD"}, {"USDCAD","EURCAD","GBPCAD","CADCHF","CADJPY","CADAUD","CADNZD"}, {"USDJPY","EURJPY","GBPJPY","CHFJPY","CADJPY","AUDJPY","NZDJPY"}, {"AUDUSD","EURAUD","GBPAUD","AUDCHF","AUDCAD","AUDJPY","AUDNZD"}, {"NZDUSD","EURNZD","GBPNZD","NZDCHF","NZDCAD","NZDJPY","NZDAUD"}, }; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { switch(SYMBOL) { case USD: i = 0; break; case EUR: i = 1; break; case GBP: i = 2; break; case CHF: i = 3; break; case CAD: i = 4; break; case JPY: i = 5; break; case NZD: i = 6; break; case AUD: i = 7; break; } for(int j=0;j<7;j++) { charts[j] = NewsSymbol[i][j]; Print("charts[",j,"] = ",charts[j]); } return(INIT_SUCCEEDED); }
Hello dear ceejay1962 ,
Thank you very much for your good guidance.
Finally it worked. :)Correct Some Mistake :
//+------------------------------------------------------------------+ //| Variables | //+------------------------------------------------------------------+ enum ENUM_SYMBOL {USD, EUR, GBP , CHF, CAD, JPY , AUD, NZD} ; input ENUM_SYMBOL SYMBOL = USD ; int i = 0 ; string charts[7] = {} ; string NewsSymbol[8][7] = { {"EURUSD","GBPUSD","USDCHF","USDCAD","USDJPY","AUDUSD","NZDUSD"}, {"EURUSD","EURGBP","EURCHF","EURCAD","EURJPY","EURAUD","EURNZD"}, {"GBPUSD","EURGBP","GBPCHF","GBPCAD","GBPJPY","GBPAUD","GBPNZD"}, {"USDCHF","EURCHF","GBPCHF","CADCHF","CHFJPY","AUDCHF","NZDCHF"}, {"USDCAD","EURCAD","GBPCAD","CADCHF","CADJPY","AUDCAD","NZDCAD"}, {"USDJPY","EURJPY","GBPJPY","CHFJPY","CADJPY","AUDJPY","NZDJPY"}, {"AUDUSD","EURAUD","GBPAUD","AUDCHF","AUDCAD","AUDJPY","AUDNZD"}, {"NZDUSD","EURNZD","GBPNZD","NZDCHF","NZDCAD","NZDJPY","AUDNZD"}, }; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { switch(SYMBOL) { case USD: i = 0; break; case EUR: i = 1; break; case GBP: i = 2; break; case CHF: i = 3; break; case CAD: i = 4; break; case JPY: i = 5; break; case AUD: i = 6; break; case NZD: i = 7; break; } for(int j=0;j<7;j++) { charts[j] = NewsSymbol[i][j]; Print("charts[",j,"] = ",charts[j]); } return(INIT_SUCCEEDED); }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello guys.
Is it possible to change the values of an array after it is defined at the beginning of the program?
for example I have declared an array with default values as follows:
I tried to change all the array values in the program as follows,
but I encountered an error. Can you please help me find out what is wrong with my code?
Thanks