Constants required in array

 

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);
 
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);
     
 
angevoyageur:



Wow, thanks.  I fail at arrays.
Reason: