Under pressure of prophesies made about the MQL4 future, I started with migration of my projects a couple of days ago, having no experience with MQL5. I am going to share some bits I experienced quite in the start:
- Neither the MQL5 is bug-free. A bug in a simple string concatenation emerged. I believe that only + operator was affected, so I started replacing the + operator by StringAdd and StringConcatenate (uff, there are a lot of them in the code).
- Many of the 'new' MQL4 functions do not have a direct counterpart in MQL5. No idea why they were introduced then.
- On the other hand, MQL4 and MQL5 have a number of identical functions. At least I thought they had, until I realised, that they differed in arguments and/or returning values. It is pretty confusing. In fact the migration from 4 to 5 seems a bit safer, as the compiler often warns about the incorrect return value type, while the other way round the MQL5 does not use the return values in many cases.
ArrayMinimum(), ArrayMaximum() need to be checked carefully, StringConcatenate as noted above.
- In fact, there are two MT5 terminals, 32 and 64 bit version. Well, it is not a problem in most cases, but it makes the DLL imports vulnerable. In fact I need to have two compiled script versions if using the Winapi functions.
- When the indicator initialisation fails in MQL5 (i.e. the OnInit returns a non-zero value), the indicator de-inits (so far so good) but then it remains attached to the chart, no message, no activity, (waiting for kinda resurrection?)
I reported this to Metaquotes Service Desk, never got an answer. Seems it's a feature.
That's my first entry. I just started, so many more might follow.
MT5 exists for a quite long period already, side by side with MT4, so there is a lot of articles and posts about migration. Many developers have libraries/includes of any kind which simplifiy porting experts and indicators from 4 to 5.
Bugs and new design decisions made by MQ are just there, and we can neither answer the questions "why" nor fix them here.
I'm not sure which issue with strings you're referring to.
MT5 exists for a quite long period already, side by side with MT4, so there is a lot of articles and post about migration. Many developers have libraries/includes of any kind which simplifiy porting experts and indicators from 4 to 5.
Bugs and new design decisions made by MQ are just there, and we can neither answer the questions "why" nor fix them here.
I'm not sure which issue with strings you're referring to.
....I'm not sure which issue with strings you're referring to.
A bug occurred with a simple statement var1 = var1 + var2; The resulting string was not terminated at proper length and a lot of garbage (like Chinese art) was appended. It was reproducible, but too deep in my code to investigate systematically.
Bugs and new design decisions made by MQ are just there, and we can neither answer the questions "why" nor fix them here.
I did not ask for an answer nor fix. I am recording experience of a MQL5 noob, in case any other noobs would follow.
Please pay attention that StringConcatenate() is not the same function on mql4 and mql5. (I know you already know but I want to highlight this for other people).
Yes, very true, the StringConcatenate is extremely confusing, unlike the StringAdd, when it clears the first argument before appending the other arguments (which is not very intuitive).
So the next experience.
- Conversion of the basic classes (i.e. most of the include folder) was going so well, that I changed the strategy. Instead of copying I linked the entire custom part of the 'include' folder from MQL4 to MQL5. Now I am checking and editing them, and nearly all the code can be expressed in a compatible syntax. Only exceptionally the conditional switch directive is required (#ifdef __MQL5__). I did not include the Orders engine though, which will need some analysis before coding, and probably hard times will come to make it compatible in some limited way.
- The very tough part is code importing the Winapi. The 64-bit compatibility requires the pointers and handles declaration changed to 64-bit length, which appeared to have a deep impact to the code, as variables are hard-coded not only in their import declarations (the easier job), but also across the code (MQL4 had only the int type not very long time ago). Fortunately, I had many unit tests written for the Winapi in MQL4, so I am reusing them in the 64-bit environment.
A bug occurred with a simple statement var1 = var1 + var2; The resulting string was not terminated at proper length and a lot of garbage (like Chinese art) was appended. It was reproducible, but too deep in my code to investigate systematically.
I use the operator for strings without problems. Perhaps it exists only in a specific version, and fixed/non-exstent in all the others.
I did not ask for an answer nor fix. I am recording experience of a MQL5 noob, in case any other noobs would follow.
Pardon me, but your first post contains the points 1 and 2: "Neither the MQL5 is bug-free." and "Many of the 'new' MQL4 functions do not have a direct counterpart in MQL5. No idea why they were introduced then.". Isn't this asking? If not, then please mark explicitly which parts of your messages require feedback, and which not. If we leave your remarks without solutions (for problems), it will hardly be an experience, but a lack of it ;-).
I also like to questioning why there must be a mq4 and mq5. Can't both been merged?
MQL4 and MQL5 are now the same single language. What you are referring to as different are MT4 and MT5 APIs.
I also do not understand why MQ decided to not support back-compatiility of MT4 APIs in MT5.
If more people ask this in the service-desk, they probably re-consider their decision.
So the next experience.
- Conversion of the basic classes (i.e. most of the include folder) was going so well, that I changed the strategy. Instead of copying I linked the entire custom part of the 'include' folder from MQL4 to MQL5. Now I am checking and editing them, and nearly all the code can be expressed in a compatible syntax. Only exceptionally the conditional switch directive is required (#ifdef __MQL5__). I did not include the Orders engine though, which will need some analysis before coding, and probably hard times will come to make it compatible in some limited way.
![MT4Orders MT4Orders](/i/code/library.png)
- votes: 14
- 2016.08.05
- fxsaber
- www.mql5.com
I use the operator for strings without problems. Perhaps it exists only in a specific version, and fixed/non-exstent in all the others.
Pardon me, but your first post contains the points 1 and 2: "Neither the MQL5 is bug-free." and "Many of the 'new' MQL4 functions do not have a direct counterpart in MQL5. No idea why they were introduced then.". Isn't this asking? If not, then please mark explicitly which parts of your messages require feedback, and which not. If we leave your remarks without solutions (for problems), it will hardly be an experience, but a lack of it ;-).
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Under pressure of prophesies made about the MQL4 future, I started with migration of my projects a couple of days ago, having no experience with MQL5. I am going to share some bits I experienced quite in the start: