Download MetaTrader 5

MQ4, array problem, error: constant expression required

To add comments, please log in or register
Sinisa Zizic
122
Sinisa Zizic  

Please help some experienced coder.

After compiling get error constant expression required.

Problem is in array, strenghts is in pips. My idea is to get stongest and weakest pairs.

Code:

                int num_array1[8] ={EURstrenght,USDstrenght,AUDstrenght,NZDstrenght,CADstrenght,GBPstrenght,CHFstrenght,JPYstrenght};

                int    maxval=ArrayMaximum(num_array1);

int    minval=ArrayMinimum(num_array1);

int    max=num_array1[maxval];

                int    min=num_array1[minval];

 

Get errors EURstrenght - constant expression required

                USDstrenght - constant expression required.... etc

Carl Schreiber
7098
Carl Schreiber  

1) Please use the SRC-button if you post code (the SRC-icon of the top line of the online editor).

2) I guess (you don't post the whole code), that EURstrenght are valiables. You cant declare array using variables - you need to do that after that!

whroeder1
15582
whroeder1  
int num_array1[8] ={EURstrenght,USDstrenght,AUDstrenght,NZDstrenght,CADstrenght,GBPstrenght,CHFstrenght,JPYstrenght};
That is only valid if EURstrength is a constant. You have to set the array elements specifically
int num_array1[8];
num_array1[0] =EURstrenght;
num_array1[1] =USDstrenght;
:
Sinisa Zizic
122
Sinisa Zizic  
That´s it!  There is no error after this correction. Thank you for help.
To add comments, please log in or register