Making a Multi-Symbol function

 

Hi,

I am trying to code a Multi-Symbol function and I need some help with it. 

I have given the pairs an option like this one:

input bool       Trade_Pair1   = 0;// Trade
input ENUM_SYMBOLS   Pair1 = GBPUSD;// Pair
input bool       Trade_Pair2   = 0;// Trade
input ENUM_SYMBOLS   Pair2 = GBPUSD;// Pair
input bool       Trade_Pair3   = 0;// Trade
input ENUM_SYMBOLS    Pair3 = GBPUSD;// Pair
input bool       Trade_Pair4   = 0;// Trade

Now I would like the pairs to pass through a bool or void or int to go to OnTick afterwards. The EA has more than 10 indicators and using the common Multi-Pair codes does not seem that suitable. 

FIRST: How would it store or calculate each of the indicators parameters?

SECOND: How can I make it loop? Checking every pair activated?

 
YThi MJ:

Hi,

I am trying to code a Multi-Symbol function and I need some help with it. 

I have given the pairs an option like this one:

Now I would like the pairs to pass through a bool or void or int to go to OnTick afterwards. The EA has more than 10 indicators and using the common Multi-Pair codes does not seem that suitable. 

FIRST: How would it store or calculate each of the indicators parameters?

SECOND: How can I make it loop? Checking every pair activated?

hi,

one from my best ways is this one:

input string symbolTab="GBPUSD;EURUSD;USDJPY";//Symbols To Trade
string symbols[];
int copy[];

int OnInit()
{
   int symbolsNumber=StringSplit(symbolTab,';',symbols);
   ArrayResize(copy,symbolsNumber);
   
   for(int i=0;i<symbolsNumber;i++)
      copy[i]=iCustom(symbols[i],...,............);
   .......
   ....... 
}

than you should use the same "for(int i......)" in the rest of program.

but please never delete the post after you get the answer, i am not working for anyone, i am helping all. (it happened with some topics)

 
Issam Kadhi:

hi,

one from my best ways is this one:

than you should use the same "for(int i......)" in the rest of program.

but please never delete the post after you get the answer, i am not working for anyone, i am helping all. (it happened with some topics)

Looks nice. I am going to try and decipher it first to see how to apply it.

Thanks a lot. As for me, I will certainly not delete it. 

 
I cannot implement it to all the handlers
 
YThi MJ:
I cannot implement it to all the handlers

didn't get you, can you explain,

 

I was thinking of creating a list like: Pair1, Pair2, Pair3...

I am attaching a code that does not work, but you might see some of the logic of what I am thinking

void TradePairs()
  {
   int i;

   if((!Trade_Pair1)&&(!Trade_Pair2)&&(!Trade_Pair3)&&(!Trade_Pair4)&&(!Trade_Pair5)&&(!Trade_Pair6)&&(!Trade_Pair7)&&(!Trade_Pair8)&&(!Trade_Pair9)&&(!Trade_Pair10)&&(!Trade_Pair11)&&(!Trade_Pair12)&&(!Trade_Pair13)&&(!Trade_Pair14)&&(!Trade_Pair15)&&(!Trade_Pair16)&&(!Trade_Pair17)&&(!Trade_Pair18)&&(!Trade_Pair19)&&(!Trade_Pair20)&&(!Trade_Pair21)&&(!Trade_Pair22)&&(!Trade_Pair23)&&(!Trade_Pair24)&&(!Trade_Pair25))
      Sym=Symbol();

   for(i=0; i<25; i++)
     {
      Sym=Pair1, Pair2, Pair3;
     }

   if(Trade_Pair1)
     {
      Sym=EnumToString(Pair1);
     }
   if(Trade_Pair2)
     {
      Sym=EnumToString(Pair2);
     }
   if(Trade_Pair3)
     {
      Sym=EnumToString(Pair3);
     }
  }
 

It could be a good idea telling the code to take the first option READ the rest, come back for the second option then READ, etc. 

Is that possible?

 
YThi MJ:

It could be a good idea telling the code to take the first option READ the rest, come back for the second option then READ, etc. 

Is that possible?

hi,

sorry but i couldn't see clearly what you meant from the code, because it is full of syntaxes errors.

but anyway, do you want to know how to continue my suggested code? (if yes i will continue writing it)


ADVICE:-- i have more than 7 years experience in coding, butu i have never written a code in that lengh-- ALWAYS try to not work a lot and write the lowest possible lines specially at the start

than after that you will focus on RAM and CPU use.


wish you the best :)

 
Issam Kadhi:

hi,

sorry but i couldn't see clearly what you meant from the code, because it is full of syntaxes errors.

but anyway, do you want to know how to continue my suggested code? (if yes i will continue writing it)


ADVICE:-- i have more than 7 years experience in coding, butu i have never written a code in that lengh-- ALWAYS try to not work a lot and write the lowest possible lines specially at the start

than after that you will focus on RAM and CPU use.


wish you the best :)

Ok. Let's try. 

 
YThi MJ:

Ok. Let's try. 

The code i sent you at the start is to take all symbols in only One input separated by ';' than add them to a string array using StringSplit(..),
Where you will find all your symbols, but never forget that the string input should never end by ';' else delete last case in the array.
Another thing that the Array should be declared as global Array Not in OnInit().
Now After you hâve all symbols there in that Array, you can use them by their positions.
I think it is better and easy way, Right?
 
YThi MJ:

Ok. Let's try. 

But If you need to use some symbols in trading and some others only on calculations, than Make another string input exactly like the first where the user will write the calculations symbols, and do the same in OnInit ().
Than in the code choose every time which Array you will use,
Is that helpful?