populating an array

To add comments, please log in or register
SirFency
173
SirFency  

I want to populate an array with currency pair values. Arrays are quite a bit different from Javascript I'm gathering. I'm totally new to programming and I took some online courses in Javascript to help prepare me to learn MQL4. I'm running into a snag with arrays. I dont understand the MQL4 documentation about arrays. The line of code below is incorrect. How would I make it correct? Everything I find in the documentation only shows arrays with a number between the brackets. like this "int someArray[50]". What am I missing?

double eurPairs[EURGBP, EURAUD, EURNZD, EURUSD, EURCAD, EURCHF, EURJPY];
SirFency
173
SirFency  
 

//declare a variable to store individual currency strength
  int EUR = 0;


//declare an array to store symbol values
   double eurTOgbp[];

//storing EUR values in array
   ArrayFill(eurTOgbp,0,1,EURGBP);
   ArrayFill(eurTOgbp,1,1,EURAUD);
   ArrayFill(eurTOgbp,2,1,EURNZD);
   ArrayFill(eurTOgbp,3,1,EURUSD);
   ArrayFill(eurTOgbp,4,1,EURCAD);
   ArrayFill(eurTOgbp,5,1,EURCHF);
   ArrayFill(eurTOgbp,6,1,EURJPY);

Compare the GBP Pairs to the EUR Pairs and store the results as an integer in the EUR variable
 for(int i=0; i<eurTOgbp[1]; i++)
     {
      if(GBPAUD > eurTOgbp[i])
        {
         EUR++;
        }
      else if(GBPAUD<eurTOgbp[i])
        {
         EUR--;

Print(EUR);
This is not working either. I get an error about array out of range but I'm telling my for loop to stop after it reads the first spot in the array so I dont understand what I'm doing wrong.
nicholi shen
2392
nicholi shen  
SirFency:
This is not working either. I get an error about array out of range but I'm telling my for loop to stop after it reads the first spot in the array so I dont understand what I'm doing wrong.
JavaScript is probably the worst language to learn mql. You'll want to pick up some C++ tutorials to learn programming concepts instead.

As far as your task you need to use an initialization list.

string symbols []={"EURUSD","EURGBP","...","..."};
SirFency
173
SirFency  
I think I have narrowed down the problem to my first ArrayFill function. I dont know why it's wrong but I think it is. In my mind I'm putting the value of EURGBP into the "Zero Position" or the first spot in the array. I am missing something still.
SirFency
173
SirFency  
nicholishen:
JavaScript it's probably the worst language to learn mql, you'll want to actually use C++ tutorials to learn...

As far as your task you need to use an initialization list.

string symbols []={"EURUSD","EURGBP","...","..."};

Thank you I will try this approach.

To add comments, please log in or register