Is MQL5 backward compatible with MQL4?

 

Hello,

Is MQL5 backward compatible with MQL4?

In other words, can I develop my EA in MQL5 and use it under MetaTrader 4?

Regards,

Pierre

 
Pierre Rougier: Is MQL5 backward compatible with MQL4? In other words, can I develop my EA in MQL5 and use it under MetaTrader 4?
  1. Developing MQL4 and running it on MT5 would be backwards compatible. Not possible, completely different Paradigm.
  2. You want forward compatible, almost never possible.
 
Cross-Platform Expert Advisor: Introduction
Cross-Platform Expert Advisor: Introduction
  • 2016.08.15
  • Enrico Lambino
  • www.mql5.com
Table of Contents Introduction Among the reasons to create cross-platform experts advisors in MetaTrader are the following: You are interested in sharing expert advisors with others, regardless of what trading platform version they use.You want to understand the differences between MQL4 and MQL5.You want to save time coding.If MetaTrader 4...
 

Cross-platform EA example.

Quantum 103
Quantum 103
  • votes: 10
  • 2017.09.20
  • Iurii Tokman
  • www.mql5.com
Сеточный советник на отложенных ордерах, индикаторы не используются. Управление советником возможно графической кнопкой. Советник автоматически выключается после окончания времени его работы, удаляет все отложенные ордера и принудительно закрывает все открытые позиции, при нажатии графической кнопки происходит тоже самое или перезапуск...
 
Pierre Rougier:

Is MQL5 backward compatible with MQL4?

NO.
The programming language is vastly different in some areas, and as such it is not directly compatible. - Jack
 
Pierre Rougier:

Is MQL5 backward compatible with MQL4?

In other words, can I develop my EA in MQL5 and use it under MetaTrader 4?

It's compatible by means of 3-rd party libraries (includes), which should be #included into your EA source code.

You may find such solutions in the source code base, blogs, and articles. For example: Ready-made Expert Advisors from the MQL5 Wizard work in MetaTrader 4

 
Stanislav Korotky:

It's compatible by means of 3-rd party libraries (includes), which should be #included into your EA source code.

You may find such solutions in the source code base, blogs, and articles. For example: Ready-made Expert Advisors from the MQL5 Wizard work in MetaTrader 4


Using a third party library isn't the same thing as the two languages being natively compatible with each other.

The question was "Is MQL5 backward compatible with MQL4". The answer is NO.
 
Jack Thomas:

Using a third party library isn't the same thing as the two languages being natively compatible with each other.

The question was "Is MQL5 backward compatible with MQL4". The answer is NO.

Everyone have a right to have own point of view. No need to post your personal opinion in bold and red.

If you understand the compatibility very strict, someone else (including OP) could accept more flexible meaning of compatibility. Then the answer is something other than NO. If you can add a single include line and your original source code continue running "as is" on other platform this is very very similar to compatibility.

Many features of MQL4 and MQL5 are common!

 
Stanislav Korotky:

Everyone have a right to have own point of view. No need to post your personal opinion in bold and red.

If you understand the compatibility very strict, someone else (including OP) could accept more flexible meaning of compatibility. Then the answer is something other than NO. If you can add a single include line and your original source code continue running "as is" on other platform this is very very similar to compatibility.

Many features of MQL4 and MQL5 are common!

I understand the compatibility probably better than most. I've been a programmer for well over 30+ years.

However the question was "Is MQL5 backward compatible with MQL4?".

The answer is NO it is absolutely not backward compatible.

Again... Using a THIRD PARTY LIBRARY is NOT the same thing as the two languages being compatible.


Also you stated:

Many features of MQL4 and MQL5 are common!

That is irrelevant and shows that you don't understand what BACKWARDS COMPATIBILITY means.

C++, Perl, and PHP have many features that are common with MQL4 and MQL5 as well.

They can import third party libraries, they can all manage mysql databases, and they can all produce the onscreen display of information.

However, simply having features that are common or similar, does NOT make them any more compatible to each other simply because of their abilities.

NO. MQL5 is NOT backwards compatible with MQL4.

- Jack

 
Pierre Rougier:

Is MQL5 backward compatible with MQL4?

NO. They are not backward compatible.


Pierre Rougier:

In other words, can I develop my EA in MQL5 and use it under MetaTrader 4?

They are two different programming languages and are not directly compatible with each other.

- Jack

 
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.


Reason: