I am working on a basket trading EA. So far I have written most of the code and I came to the basket BUY and SELL Buttons function.

What I have so far is several arrays to build the buttons and feed the several formulas with the needed values. I now have the following:

string sym[]={"EURUSD", "GBPUSD", "USDJPY", "USDCHF", "NZDUSD","AUDUSD","USDCAD"}; // already existing

string EURUSDb[]={"EURUSD", "EURGBP", "EURJPY", "EURCHF", "EURNZD", "EURAUD", "EURCAD"}; //already existing

....and more arrays with different symbols to create the correct basket for the remaining pairs.

In the OnChartEvent section, I want the following to be possible:

for(i=0; i<=6; i++)


obj=sym[i]+DoubleToString((i+4),0); //to match the correct denomination of the button - not of much importance in this case.

if(sparam)=obj //the button has been pressed


for(r=0; r<=6; r++)

Ordersend(EURUSDb[r], .......); // this is where I have the problem! At the first run of the loop when i=0, sym[0]=EURUSD - I can construct the array name to be called in the next function as such: sym[0]+"b". How to use the (sym[0]+"b") result to call the correct array, in this case: EURUSDb[r]. I tried (sym[i]+"b")[r] to get the equivalent of EURUSDb[r] but did not work.


ObjectSetString(...OBJPROP_STATE, false);


I know it can be done with the if loop to assign manually the array to be used in the ordersend function and/or add a 2 dimentional array to the rest of the array list. I dont want to create additional lines or any additional arrays - the rest of the code is already built around the current arrays and would really not want to rewrite the whole code before it is confirmed there's no other way to achieve what I am after.

If any function exist to do what I have explained above (hoping that I have explained it well enough), please show me the way or any other simple/easy workaround to this case.

I really appreciate your help.