TFMigrate(tf);

 

Hello freinds,

 

I tried to imigarte a MQL4 file to MQL% file and I use the good article at: https://www.mql5.com/en/articles/81.

 

There it uses the line: ENUM_TIMEFRAMES timef=TFMigrate(tf);

 

The compilre says: 'TFMigrate' - function is not defined.

 

What can I do?

 

Thanks
 

Migrating from MQL4 to MQL5
  • 2010.05.17
  • Sergey Pavlov
  • www.mql5.com
This article is a quick guide to MQL4 language functions, it will help you to migrate your programs from MQL4 to MQL5. For each MQL4 function (except trading functions) the description and MQL5 implementation are presented, it allows you to reduce the conversion time significantly. For convenience, the MQL4 functions are divided into groups, similar to MQL4 Reference.
 
crossy:

What can I do?

You can add the function:

ENUM_TIMEFRAMES TFMigrate(int tf)
  {
   switch(tf)
     {
      case 0: return(PERIOD_CURRENT);
      case 1: return(PERIOD_M1);
      case 5: return(PERIOD_M5);
      case 15: return(PERIOD_M15);
      case 30: return(PERIOD_M30);
      case 60: return(PERIOD_H1);
      case 240: return(PERIOD_H4);
      case 1440: return(PERIOD_D1);
      case 10080: return(PERIOD_W1);
      case 43200: return(PERIOD_MN1);
      
      case 2: return(PERIOD_M2);
      case 3: return(PERIOD_M3);
      case 4: return(PERIOD_M4);      
      case 6: return(PERIOD_M6);
      case 10: return(PERIOD_M10);
      case 12: return(PERIOD_M12);
      case 16385: return(PERIOD_H1);
      case 16386: return(PERIOD_H2);
      case 16387: return(PERIOD_H3);
      case 16388: return(PERIOD_H4);
      case 16390: return(PERIOD_H6);
      case 16392: return(PERIOD_H8);
      case 16396: return(PERIOD_H12);
      case 16408: return(PERIOD_D1);
      case 32769: return(PERIOD_W1);
      case 49153: return(PERIOD_MN1);      
      default: return(PERIOD_CURRENT);
     }
  }

to your code.

The second way is to copy initmql4.mqh to MQL5\Include\ folder and add

#include <initmql4.mqh>
 
Automated-Trading:

You can add the function:

to your code.

The second way is to copy initmql4.mqh to MQL5\Include\ folder and add

Thanks Quantum,

 

I'm sure that there are many fixed  MQH files that include the collection of the all possible migrations. Can you attach it or maybe just give me the links of them.

 

Thanks 

 
Спасибі! Дякую.
 
Thank you!
 
Automated-Trading:

You can add the function:

to your code.

The second way is to copy initmql4.mqh to MQL5\Include\ folder and add

Hi 
I am faced with the same problem ,

I copied  initmql4.mqh to include folder and now compiler gives Error :

can't open "C:\Users\Reza\AppData\Roaming\MetaQuotes\Terminal\03EFA09D725A1F639868556764D11623\MQL5\include\initmql4.mqh" include file

Please tell me what should I do ?

 

You can try to add it as a resource or just copy the code in the Mqh file to your EA.

 
Marco vd Heijden:

You can try to add it as a resource or just copy the code in the Mqh file to your EA.

Hi Marco vd Heijden

Thank you .

thanks for your response.


I don't want to copy this codes because I'm converting  mq4 to mq5 and there is many errors and I don't want to make my codes very crowded.
 how resources are working ? 
Do you know why I'v got that error ?

 

https://www.mql5.com/en/docs/runtime/resources

I know that there are many errors but in order to solve it you have to be specific.

This means the code and the exact error.

Obviously can't open "C:\Users\Reza\AppData\Roaming\MetaQuotes\Terminal\03EFA09D725A1F639868556764D11623\MQL5\include\initmql4.mqh" include file

Means that it is unable to locate the file.

We can not solve this by code examples, it is you who has to make sure that the compiler can find the file.

Furthermore i can see the 'TFMigrate' - function is not defined, this seems to be solved now.

But i do not see any other error you posted so unable to help further.

Documentation on MQL5: MQL5 programs / Resources
Documentation on MQL5: MQL5 programs / Resources
  • www.mql5.com
MQL5 programs / Resources - Reference on algorithmic/automated trading language for MetaTrader 5
Reason: