Download MetaTrader 5

How to convert arraytimeframe from mql4 to mql5 ?

To add comments, please log in or register
sharteel
100
sharteel  

Hi,

 I use this code for my MTF indicator on chart in MQL4, i'm working for move to mql5:

int tframe[]={1,5,15,30,60,240,1440,10080,43200};
int tfnumber=9;
double IndVal[9];

for(int x=1;x<tfnumber+1;x++) {
      
      TREND0=iMA(Symbol(),tframe[x-1],21,0,MODE_SMA,PRICE_CLOSE);
      TREND1=iMA(Symbol(),tframe[x-1],50,0,MODE_SMA,PRICE_CLOSE);
      TREND2=iMA(Symbol(),tframe[x-1],100,0,MODE_SMA,PRICE_CLOSE);


        
        if( TREND0>TREND1 && TREND1>TREND2 )
        {
        IndVal[x-1]=1;
        }
        else if( TREND0<TREND1 && TREND1<TREND2 )
        {
        IndVal[x-1]=-1;
        }        
        else IndVal[x-1]=0;

}

With MQL5 EDITOR, i have this error when i compile: 'tframe' - can't convert enum

 

Anyone can help me for updating the code in mql5 ?

 

Regards. 

hasayama
612
hasayama  
sharteel:

Hi,

 I use this code for my MTF indicator on chart in MQL4, i'm working for move to mql5:

With MQL5 EDITOR, i have this error when i compile: 'tframe' - can't convert enum

 

Anyone can help me for updating the code in mql5 ?

 

Regards. 

 

To present TFs an enumeration is used now, so define your TF variable as an enum:

ENUM_TIMEFRAMES tframe[] = { PERIOD_M1, PERIOD_M5, PERIOD_M15, PERIOD_M30, PERIOD_H1, PERIOD_H4, PERIOD_D1, PERIOD_W1, PERIOD_MN1 };

 

To add comments, please log in or register