Interesting finding in MQL4 (not for real use....)

 

Apparently MQL4 has these structures defined, which come from MQL5 and find their usage in MQL5.

    MqlParam                mql_param;

Print(sizeof(MqlParam));

// Structure is fully functional in MQL4
    double d_val = mql_param.double_value;
    long l_val = mql_param.integer_value;
    string s_val = mql_param.string_value;
    ENUM_DATATYPE e_val = mql_param.type;


    MqlBookInfo             mql_book;

Print(sizeof(MqlBookInfo));

// Partially functional in MQL4
    double d2_val = mql_book.price;     
    uint e2_val = (uint)mql_book.type;          // ENUM_BOOK_TYPE is missing in MQL4
    long l2_val = mql_book.volume;


// Interesting, in MQL5 this structure has another 
// value, not present in MQL4
    // double d3_val = mql_book.volume_real;

Have there ever been plans to iintegrate book-details to MT4?? - At least this could be some evidence for such plans.

For the fun of it.


Here is how I found out about it:

While developing the MQL4-Portion of the library lib_debug from Code Base (Link) This appeard as compiling, but not resolving as the relevant functions were disabled for MQL4. - I came across and saw, I could address the in MQL5 documented members (mostly).

Funny, how things show up over time.


As said, for entertainment, not for usage, I guess.... Or has anyone a usage-scenario for these data structures in MQL4?

 

There was probably a time when MetaQuotes was working on completely unifying both platforms, but it probably become too problematic and decided to just stop developing MT4/MQL4.

 
Fernando Carreiro #:

There was probably a time when MetaQuotes was working on unifying both platforms, but it probably become too problematic and decided to just stop developing MT4/MQL4.




I found so many things within the last week while working on the project, it's incredible how traces show up.

It's for the better, they dropped MQL4 as a language, it outgrew itself for sure.

MQL5 is much better structured in so many aspects.

But it is fun to make code work for both languages in almost one go.

The main shared base is big enough, if taken into consideration, to actually code for both with very similar results.

One thing, I noticed is the journal output. MT5 uses a font with same spacing for every character, while MT4 has varying spacing font.

It's impossible to line up the output over multiple lines. And the top down approach is also a little strange, and requires some adjustment time. At least for me.
 

As a side note, in MT5 I use this hack to print names of structure fields (as a fast reference).

It can also print "un-documented" fields. 

Not applicable for MT4.

//+------------------------------------------------------------------+
//| Print sructure fields.                                           |
//+------------------------------------------------------------------+
template <typename T>
void PrintStruct()
  {
   T st1 = {};
   T a[1]; a[0] = st1; // one-element array
   Print(typename(st1));
   Print("  {"); ArrayPrint(a); Print("  };");
  }

void OnStart(void)
  {
   PrintStruct<MqlRates>();
   PrintStruct<MqlTradeRequest>();
  }


/*
struct MqlRates
  {
                 [time] [open] [high] [low] [close] [tick_volume] [spread] [real_volume]
[0] 1970.01.01 00:00:00 0.0000 0.0000 0.000 0.00000             0        0             0
  };

struct MqlTradeRequest
  {
    [action] [magic] [order] [symbol] [volume] [price] [stoplimit] [sl] [tp] [deviation] [type] [type_filling] [type_time]        [expiration] [comment] [position] [position_by] [reserved]
[0]        0       0       0 null      0.00000 0.00000     0.00000 0.00 0.00           0      0              0           0 1970.01.01 00:00:00 null               0             0        ...
  };
*/
 
amrali #:

As a side note, in MT5 use this hack to print names of structure fields (as a fast reference).

It can also print "un-documented" fields. 

Not applicable for MT4.



Good idea, to bad it can't be stringified.
 
Dominik Christian Egert:

Apparently MQL4 has these structures defined, which come from MQL5 and find their usage in MQL5.

Have there ever been plans to iintegrate book-details to MT4?? - At least this could be some evidence for such plans.

For the fun of it.


Here is how I found out about it:

While developing the MQL4-Portion of the library lib_debug from Code Base (Link) This appeard as compiling, but not resolving as the relevant functions were disabled for MQL4. - I came across and saw, I could address the in MQL5 documented members (mostly).

Funny, how things show up over time.


As said, for entertainment, not for usage, I guess.... Or has anyone a usage-scenario for these data structures in MQL4?

In early 2014, they "merge" both languages somehow. A lot MQL5 functions and structures where added to MQL4, etc... I don't think there was a plan to integrate DOM to MT4, but they copied a lot of things without paying much attention to the details.
 
Dominik Christian Egert #:


Good idea, to bad it can't be stringified.
It could be someday...