Download MetaTrader 5
To add comments, please log in or register
The entire MQL5.community history on a single page!
slavename
64
slavename 2014.07.16 19:33 

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
28550
Alain Verleyen 2014.07.16 20:50  
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 2014.07.16 21:17  
angevoyageur:



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