Download MetaTrader 5

Is MQL5 backward compatible with MQL4? - page 2

To add comments, please log in or register
Jack Thomas
2125
Jack Thomas  
fxsaber:

I understand the compatibility probably better than most. I've been a programmer for well over 40+ (forty) years.

So I'm right, and you're wrong!

-Fxsaber


PS Dont be upset. Renat (CEO Metaquotes) understands programming worse than you.

Only 27 years old... Therefore, you are cool!

FXsaber you are wrong.


Please do not give false information to people.

Here is absolute proof MQL4 is NOT compatible with MQL5.

DEMO MQL4 EA SOURCE CODE

#property copyright "Not applicable"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

int OnInit(){ 
//This code will execute once when the EA is loaded.
   for(int x=0; x<10; x++){
      Print("The high value of bar "+(string)x+" is "+DoubleToString(iHigh(Symbol(),PERIOD_CURRENT,x),(int)MarketInfo(Symbol(),MODE_DIGITS)));
   }
return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason){}


void OnTick(){}

Copy and paste the above source code into the Metatrader 4 code editor as a new EA.

Just name it MQL4_DEMO.mq4

Click compile and you should see something similar as shown in this screenshot.

You will  see that the code compiles without error using the MT4 code editor.
Now open a new chart and add that EA to it.
Now click on the Experts tab to see the output of the bar high information.
It will look something like the image below.

Now then.... Repeat that process with the MT5 code editor.

Name your file MQL5_DEMO

Copy and paste that exact code as provided for the demo above, into the MT5 code editor and click compile.
When you click the compile button you will see that it WILL NOT and CANNOT compile because MQL4 and MQL5 are NOT compatible languages.




Stop given FALSE information to people. MQL4 is NOT compatible with MQL5.

END OF DISCUSSION.


fxsaber
10779
fxsaber  
Jack Thomas:

Stop given FALSE information to people.

Crossplaform code

// MQL4&5-code

#property copyright "Not applicable"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

#ifdef __MQL5__

int    MarketInfo( const string Symb, const ENUM_SYMBOL_INFO_INTEGER Property ) { return((int)SymbolInfoInteger(Symb, Property)); }

#define MODE_DIGITS    SYMBOL_DIGITS

#define DEFINE_TIMESERIE(NAME,FUNC,T)                                                                         \
  class CLASS##NAME                                                                                           \
  {                                                                                                           \
  public:                                                                                                     \
    static T Get(const string Symb,const int TimeFrame,const int iShift)                                      \
    {                                                                                                         \
      T tValue[];                                                                                             \
                                                                                                              \
      return((Copy##FUNC((Symb == NULL) ? _Symbol : Symb, _Period, iShift, 1, tValue) > 0) ? tValue[0] : -1); \
    }                                                                                                         \
                                                                                                              \
    T operator[](const int iPos) const                                                                        \
    {                                                                                                         \
      return(CLASS##NAME::Get(_Symbol, _Period, iPos));                                                       \
    }                                                                                                         \
  };                                                                                                          \
                                                                                                              \
  CLASS##NAME NAME;                                                                                           \
                                                                                                              \
  T i##NAME(const string Symb,const int TimeFrame,const int iShift)                                           \
  {                                                                                                           \
    return(CLASS##NAME::Get(Symb, TimeFrame, iShift));                                                        \
  } 

DEFINE_TIMESERIE(High, High, double)

#endif // __MQL5__

int OnInit(){ 
//This code will execute once when the EA is loaded.
   for(int x=0; x<10; x++){
      Print("The high value of bar "+(string)x+" is "+DoubleToString(iHigh(Symbol(),PERIOD_CURRENT,x),(int)MarketInfo(Symbol(),MODE_DIGITS)));
   }
return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason){}


void OnTick(){}


Are there any other examples?

Jack Thomas
2125
Jack Thomas  
fxsaber:

Crossplaform code

Are there any other examples?


Does the demo code I provided in my example COMPILE and EXECUTE correctly with MT4 & MT5 without modification?

NO it doesn't because the two languages are not compatible.

The code would not work "out of the box" because MT4 and MT5 use different programming languages.

The only reason the code will execute on the MT5 platform is because you added a large amount of code in order to make it compile and run.

You had to add a lot of code just to run a simple MQL4 data collection loop.

Does MT5 Support iHigh, iLow, iOpen, iClose?

NO because MQL4 and MQL5 are NOT language compatible.

Sergey Golubev
Moderator
101552
Sergey Golubev  

Hi @Jack Thomas


I can not send PM message to you (because you use some settings in your profile to accept PM from the friends only).

I have one request - please, use normal font and color when posting. Why?
People are complainining - your posts with bold blue/read color look like aggressive posts ... no one is posting like that on the forum ...

----------------

So, please, use normal font and color when posting.

Jack Thomas
2125
Jack Thomas  
Sergey Golubev:

Hi @Jack Thomas


I can not send PM message to you (because you use some settings in your profile to accept PM from the friends only).

I have one request - please, use normal font and color when posting. Why?
People are complainining - your posts with bold blue/read color look like aggressive posts ... no one is posting like that on the forum ...

----------------

So, please, use normal font and color when posting.

Why allow people to use colors if you don't want them used? That's absurd.

I'm sorry but it really is absurd for someone to complain because I used COLORS.

Yes I used colors to make a point.

I will try and limit my use of colors and such in the future, However, my posts are VALID and my information is correct as I have presented.

I sent you a friends request so you can contact me.

Sergey Golubev
Moderator
101552
Sergey Golubev  
Jack Thomas:

Why allow people to use colors if you don't want them used? That's absurd.

I'm sorry but it really is absurd for someone to complain because I used COLORS.

Yes I used colors to make a point.

I will try and limit my use of colors and such in the future, However, my posts are VALID and my information is correct as I have presented.

I sent you a friends request so you can contact me.


It is nothing with me.

If someone is using the color to post a text (not one colored word; just whole the text with colors in bold especially with aggressive colors such as blue and read) so the people understand such the posts as the aggression against them, or as the poster is getting angry for something ...


That is nothing special - if they complained so I as moderator should re-act.

fxsaber
10779
fxsaber  
Jack Thomas:


Does the demo code I provided in my example COMPILE and EXECUTE correctly with MT4 & MT5 without modification?

NO it doesn't because the two languages are not compatible.

The code would not work "out of the box" because MT4 and MT5 use different programming languages.

The only reason the code will execute on the MT5 platform is because you added a large amount of code in order to make it compile and run.

You had to add a lot of code just to run a simple MQL4 data collection loop.

Only one string!

// MQL4&5-code

#property copyright "Not applicable"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

#include <mql4_to_mql5.mqh>

int OnInit(){ 
//This code will execute once when the EA is loaded.
   for(int x=0; x<10; x++){
      Print("The high value of bar "+(string)x+" is "+DoubleToString(iHigh(Symbol(),PERIOD_CURRENT,x),(int)MarketInfo(Symbol(),MODE_DIGITS)));
   }
return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason){}


void OnTick(){}

Does MT5 Support iHigh, iLow, iOpen, iClose?

NO because MQL4 and MQL5 are NOT language compatible.

You are wrong. You do not have enough experience to write mql4_to_mql5.mqh.

Jack Thomas
2125
Jack Thomas  
fxsaber:

Only one string!

You are wrong. You do not have enough experience to write mql4_to_mql5.mqh.


Yes or No.

Without using a third party library, does MT5 support iHigh,iLow,iOpen,iClose natively?

The answer is NO.

MQL4 is NOT language compatible with MQL5, which is what the OP asked.

fxsaber
10779
fxsaber  
Jack Thomas:

Stop. You are acting like a child.

Yes or No.

Without using a third party library, does MT5 support iHigh,iLow,iOpen,iClose natively?

These functions are not part of the language (MQL4). These are part of the History API.

Do you understand the difference between languages and API?

Marco vd Heijden
Moderator
6137
Marco vd Heijden  

MQL4 to MQL5 is not compatible.(without function conversion libs)

However, MQL5 to MQL4 is compatible to some extend,

There are some issues with for example timeframes and trade functions,

But for the most of it, it's usable.

Now here is a list of MQL4 Functions: https://docs.mql4.com/function_indices

Sorry to bust your bubble saber, but iHigh,iLow,iOpen,iClose are in there.

List of MQL4 Functions - MQL4 Reference
List of MQL4 Functions - MQL4 Reference
  • docs.mql4.com
Reads from the file of the CSV type a string of one of the formats: "YYYY.MM.DD HH:MM:SS", "YYYY.MM.DD" or "HH:MM:SS" - and converts it into a datetime value
To add comments, please log in or register