Is MQL5 backward compatible with MQL4? - page 2

 
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?

 
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.

 

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.

 
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.

 
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.

 
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.

 
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.

 
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?

 

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
 
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.

Example EA please!

Reason: