Array resize bug in beta build 530 - page 3

 
RaptorUK:

I'm not familiar with MT3 but I assume that code that ran on MT3 also ran on MT4 . . . this is the problem with MT4 --> MT5 and is why the situation is different.

The majority of MT4 users can't code, if their favourite Indicators on MT4 don't exist on MT5 then they won't use MT5.

As far as I know MT3 code don't ran on MT4, the language is very different. This debate about MT4/MT5 is endless, there is a lot of factors that leads to the survival of MT4, I am not even sure that MT5 was intended to completely replace MT4.

Anyway, about the new version, Metaquotes said it will be backward compatible at ex4 level, but not really at mq4 level.

 

I had a quick look through the new metaeditor help, the new version mql4 looks a lot more different from the old version than I thought it would be.

 
angevoyageur:

As far as I know MT3 code don't ran on MT4, the language is very different. This debate about MT4/MT5 is endless, there is a lot of factors that leads to the survival of MT4, I am not even sure that MT5 was intended to completely replace MT4.

Anyway, about the new version, Metaquotes said it will be backward compatible at ex4 level, but not really at mq4 level.

Compatibility with current .ex4 Indicators, Scripts and EAs is not just about the language, it's also about the Terminal and changes to how it works. For example, changes to the Strategy Tester could break EA's designed to be primarily used in the Strategy Tester, while the same EA works OK on a live chart it no longer would perform it's primary function . . .
 
angevoyageur:

As far as I know MT3 code don't ran on MT4, the language is very different. This debate about MT4/MT5 is endless, there is a lot of factors that leads to the survival of MT4, I am not even sure that MT5 was intended to completely replace MT4.

Anyway, about the new version, Metaquotes said it will be backward compatible at ex4 level, but not really at mq4 level.

To me it looks like it is supposed to be backwards compatable at the mq4 level, the included custom indicators are the original mql4 versions with a change the name of the init() function they compile in the new compiler and run on the new terminal, that has to mean we can still code indicators using IndicatorCounted() if we want to ...

init() is now called int OnInit(void) and it does return(INIT_SUCCEEDED);

 
SDC:

To me it looks like it is supposed to be backwards compatable at the mq4 level, the included custom indicators are the original mql4 versions with a change the name of the init() function they compile in the new compiler and run on the new terminal, that has to mean we can still code indicators using IndicatorCounted() if we want to ...

init() is now called int OnInit(void) and it does return(INIT_SUCCEEDED);

Sorry but it won't be backward compatible at mq4 level, see the announcement of first beta.

Differences from the old MQL4 version:

  • Changed the priority of AND/OR logical operations. Now, everything is similar to the standard C/C++

  • Introduced shortened evaluation of logical expressions. Now, when a logical expression is evaluated before reaching its end, the remaining subsequent expressions are not evaluated, like in C/C++.

  • Only integer values are now used in switch operator. Real values could have been used before

  • A dot symbol cannot be used in variable names any more. Also, '@', '$' and '?' symbols cannot be used in variable names

  • Tightened requirements for start function. Parameters could have been set in start function before. Now, all init, start, deinit, OnInit, OnStart, OnTick, OnTimer and other entry points should exactly match their signatures

  • Due to expansion of keywords, such names as short, long, float, const, virtual, input, delete, new, do, char cannot be used now

  • Now, imported dll functions cannot accept MQL string arrays as a parameter, like in MQL5

  • Introduced predefined _Period, _Symbol, _LastError, _CriticalError, _StopFlag, _Point, _Digits, _UninitReason, _RandomSeed variable names that may come into conflict with simple variables declared under the same names in existing source files

  • datetime type has become an 8-byte one, like in MQL5.

The differences are not critical and can be easily corrected in the code. In return, we access multiple MQL5 features, improved execution speed and much more strict quality control.

It's not heavy changes, but it means no 100% backward compatible (mq4).
 
SDC:

...

init() is now called int OnInit(void) and it does return(INIT_SUCCEEDED);

You can use both version.
 

I like the new features in metaeditor

 

I think when the new version is released it will cause a lot of confusion on the forum for newbies because the new mql4 documentation is based on mql5 coding. That means much of what is described on this forum and in the codebase will be contradicted by the mql4 docs.

Setting up an indicator buffer from the new mql4 docs: (This actually has errors in it and won't compile)

#property copyright "2009, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
 
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots   1
//---- plot MA
#property indicator_label1  "MA"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- input parameters
input bool               AsSeries=true;
input int                period=15;
input ENUM_MA_METHOD     smootMode=MODE_EMA;
input ENUM_APPLIED_PRICE price=PRICE_CLOSE;
input int                shift=0;
//--- indicator buffers
double                   MABuffer[];
int                      ma_handle;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   if(AsSeries) ArraySetAsSeries(MABuffer,true);
   Print("Indicator buffer is timeseries = ",ArrayGetAsSeries(MABuffer));
   SetIndexBuffer(0,MABuffer,INDICATOR_DATA);
   Print("Indicator buffer after SetIndexBuffer() is timeseries = ",
         ArrayGetAsSeries(MABuffer));
   
//--- change the oredr of accessing elements of the indicator buffer
   ArraySetAsSeries(MABuffer,AsSeries);
   
   IndicatorSetString(INDICATOR_SHORTNAME,"MA("+period+")"+AsSeries);
//---
   ma_handle=iMA(Symbol(),0,period,shift,smootMode,price);
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//--- Copy the values of the moving average in the buffer MABuffer
   int copied=CopyBuffer(ma_handle,0,0,rates_total,MABuffer);
 
   Print("MABuffer[0] = ",MABuffer[0]);// Depending on the value AsSeries
                                      // Will receive a very old value
                                      // Or for the current unfinished bar
 
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
SDC:

I think when the new version is released it will cause a lot of confusion on the forum for newbies because the new mql4 documentation is based on mql5 coding. That means much of what is described on this forum and in the codebase will be contradicted by the mql4 docs.

Setting up an indicator buffer from the new mql4 docs: (This actually has errors in it and won't compile)

Yes you are right, it will be a difficult transition. However, I think it will difficult not for newbies but for experimented mql4 coder that doesn't know mql5 yet. In General, newbies don't read the documentation
 

Have you already been coding in MQL5 angevoyageur ?

Reason: