Download MetaTrader 5

Constants required in array

To add comments, please log in or register
slavename
64
slavename  

Trying to make an array of 4 EMAs, but getting error that the defined values of the array must be constants.  Is there a workaround?

 

double h4Long = iMA(NULL,PERIOD_H4,365,0,MODE_EMA,PRICE_CLOSE,1);
double d1Long = iMA(NULL,PERIOD_D1,365,0,MODE_EMA,PRICE_CLOSE,1);
double h4Short = iMA(NULL,PERIOD_H4,150,0,MODE_EMA,PRICE_CLOSE,1);
double d1Short = iMA(NULL,PERIOD_D1,150,0,MODE_EMA,PRICE_CLOSE,1);
     
double lines[4] = {h4Long, d1Long, h4Short, d1Short};
ArraySort(lines,WHOLE_ARRAY,0,MODE_DESCEND);
Alain Verleyen
Moderator
32399
Alain Verleyen  
alyehoud:

Trying to make an array of 4 EMAs, but getting error that the defined values of the array must be constants.  Is there a workaround?

double lines[4];
lines[0] = iMA(NULL,PERIOD_H4,365,0,MODE_EMA,PRICE_CLOSE,1);
lines[1] = iMA(NULL,PERIOD_D1,365,0,MODE_EMA,PRICE_CLOSE,1);
lines[2] = iMA(NULL,PERIOD_H4,150,0,MODE_EMA,PRICE_CLOSE,1);
lines[3] = iMA(NULL,PERIOD_D1,150,0,MODE_EMA,PRICE_CLOSE,1);
     
slavename
64
slavename  
angevoyageur:



Wow, thanks.  I fail at arrays.
To add comments, please log in or register