Difficulties of translation :)

 

I want to tell you how I converted my project from MQL4 to 5 in one night. I am not bragging, I just want to tell about my practice and it turned out to be very simple.)

So, yesterday afternoon tired, lay down for half an hour, and woke up at half past one in the morning. I think I snored, what to do now, I will never get to sleep.

I`ve been thinking about switching my scalper project from MT4 to MT5 with hedging, I`ve been using hedging-demo from robot site for a long time but had no time to really use it. The main goal is to test using real robot ticks. I also want to run the optimizer in the cloud, the speed there is really good.

At the moment I'm running the model in Matlab, but it is a simplified version and it is getting harder and harder to synchronize changes of the code and the model. Let's say the model is constantly lagging behind the real MQL4 code.

********** Migration Process *****

So, my project consists of one .mq4 file and a bunch of classes in .mqh. I have moved everything to 5, renamed .mq4 to .mq5, left the classes as they are. Started compiling, 100500 errors of course. Ok, we are not afraid of troubles and look at errors. The bulk of them are related to MarketInfo, they occur almost everywhere. Ok, I'm a lazy kitty, I'm not allowed to clean it up by hand )) I already have an MQL4/5 project in Visual Studio.

By the way, I've watched my old video from 2011 carefully preserved on YouTube. I've learned how to configure 2010 studio to accept MQL files as plus files. Nothing has changed, you can use it now.

The video from 2011, I could swear at MQL4, the situation is different now, the language is normal )) I'm just too lazy to reread it, but some echoes from the past may slip through.

https://www.youtube.com/watch?v=oQs4qqwhqzg

So, I've uploaded everything to studio, the nice thing about it is that searching and replacing can be done all at once throughout the project and not by one file at a time. I have replaced all MarketInfo with MQL5 analogues. After a couple of minor corrections, all errors, as expected, have remained in the COrderManager class. This is my class that manages orders, builds and modifies grids and other stuff.

It must have taken me about 3 hours to redesign it. Used CTrade Standard Library class, but I had to give birth to a baby from it, because some features were missing.

------------------------

Conclusion. All this moaning about how difficult it is for a poor programmer to switch to 5 is bullshit! During the transition I cooked a big potato with meat, went for a night walk, like to walk at night, watched a little movies with Bruce W., and made some improvements in the places I couldn't get to. Now it's quite possible to make a reboot, I was recently reminded of an old promise, and the topic came up again the other day.

Yes, the COrderManager class lost a lot of weight using the Standard Library

Настройка Visual Studio 2010 для редактирования MQL файлов
Настройка Visual Studio 2010 для редактирования MQL файлов
  • 2011.07.01
  • www.youtube.com
Как известно, редактор Metatrader 4 далек от совершенства. Часто удобно редактировать большие проекты в VS2010. На этом видео я показываю процесс настройки.
 
Andrey F. Zelinsky:

How do you understand "improved those places" after "went for a night walk"?

Did you go for a walk at night or did you go for a walk?

I haven't had to sit in an office for a long time, I often go for a walk at night ) I have improved some places in the project that I wanted to change long ago but I was too lazy to do it anyway. I have got ready for such an event, conversion and redid many things.

Andrey, "go for a walk" and "drink" are two different things )).

 

Alexei, a question for you:

How long and difficult is it to translate projects that are written in procedural style? Why procedural? - I'm used to it, I have one template for all occasions, write 3-5 lines for conditions in it, and any owl is ready in half an hour with all the debugging

Next:

Is it possible to rewrite the position opening function to apply it in the same way as in quad, just got used to their names and usage over the years, and don't need to plug in any libraries.

Well, and a block of conditions for opening and creating charts:

Lots more graphics, wrote once on five, so there's something done through .opa time and price of selecting the first point and the second. In the fourth, ObjectSetInteger(0,nm,OBJPROP_TIME1, t1) and ObjectSetInteger(0,nm,OBJPROP_TIME2, t2), but in the fifth, such a construction does not work(

Thanks in advance for the answer!

 
Alexey Volchanskiy:

...

Conclusion. All this moaning about how hard it is for a poor programmer to switch to an A is bullshit! ...

Don't confuse God's gift with an egg. If an EA is working with multiple orders and translated into netting, this is an unreal task.
 

I think it's easier not to port the code. It is easier to write from scratch. This way it will be of higher quality.

 
Dmitry Fedoseev:
Don't confuse God's gift with the egg. If an EA is working with multiple orders and moving to netting, it is an unrealistic task.

Of course, I wrote in the first post"I have long wanted to move my scalper project from MT4 to MT5 with hedging, I've already started hedging demos from Robo, but I haven't had the time. "You must have missed these details.

That's why I didn't switch to MT5 while there was only netting. Now, with the hedge, I'm slowly crawling over.

The post was about the purely technical side of the transition.

 
Anton Zverev:

I think it's easier not to port the code. It is easier to write from scratch. It will be of higher quality that way.

Why? The languages are the same, functions to access timeseries are different, some others, this is solved in VS by replacing throughout the project, as I wrote. It's quick and uncomplicated. Some difficulties with the trading part, I had to introduce position handling into the class in addition to order processing. But in principle it's not a big deal either.

Once again, just in case - I mean hedge.

 
Vitaly Muzichenko:

Alexei, a question for you:

How long and difficult is it to translate projects that are written in procedural style? Why procedural? - I'm used to it, I have one template for all occasions, write 3-5 lines for conditions in it, and any owl is ready in half an hour with all the debugging

Next:

Is it possible to rewrite the position opening function to apply it in the same way as in quad, just got used to their names and usage over the years, and don't need to plug in any libraries.

And a block of conditions to open and create a chart:

Lots more graphics, I wrote once on five, so something was done through the .opa there, the time and price of selecting the first point and the second. In the fourth, ObjectSetInteger(0,nm,OBJPROP_TIME1, t1) and ObjectSetInteger(0,nm,OBJPROP_TIME2, t2), but in the fifth, such a construction does not work(

Thanks in advance for the answer!

Vitaly, you can leave everything in procedural style, no one is forcing you to use OOP. The Standard Library is just clear to me, I've created my own class from it, I've augmented some things. And I've done everything on OOP.

I will answer in reverse order ))

1. I re-did the script with graphics, there are some differences, but very slight. Basically, I have to specify window and subwindow explicitly, it was not necessary in 4.

2. As for opening positions, if the CTrade class is used, it has almost direct analogues of the MQL4 functions

3. I think it won't take long.

If you mean freelancing, you can get used to it very quickly. Basically you have to get used to the fact that orders, trades and positions are different things, also on hedges.

 
Anton Zverev:

I think it's easier not to port the code. It is easier to write from scratch. This way it will be of higher quality.

Sometimes it is useful to quit your job, wife, and full life and start from scratch. I've done it many times. Everything turns out better and of higher quality.)
 
Alexey Volchanskiy:
Sometimes it can be useful to give up your job, your wife, your life of contentment and start from scratch. I have done so many times. It gets better and better )))
))
 
I'm going to get jumped on now - I can feel it. You should write in OOP style and you'll be happy.
And then a move like this will be an easy night's walk.
Reason: