PLO - page 2

 
Interesting:

In fact, with a normal approach the OOP implemented in MQL5 (together with the resources of the terminal itself) will give a significant increase in speed.

What speed of operation are you referring to, the speed of the program or the speed of its writing?

 
Integer:

OOP doesn't increase the performance. It has some benefit - for example, if there is some function called with some parameters (say, EMA calculation), a static variable is used in the function to store the previous EMA value. Since the function stores the last value on the basis of which the calculations will be performed, it cannot be called with other parameters (symbol, timeframe, smoothing period) when the function is called next, therefore if the function needs to be called with different parameters, it is necessary to make a copy of it with a different name or use a global variable passed by reference instead of a static one. This is the only case where it's more convenient to use object - you load an object instance, set its parameters and then call the method without parameters. If the object includes methods, which execution does not depend on previous executions or in general on any parameters with which the object is loaded, it does not give anything but consumption of resources.

It does, it does, it really does. But it all depends on experience, imagination and crookedness of programmer's hands (in that order)... :)

And in fact even if to assume that OOP (with the most awful approach to it) doesn't increase the runtime, or increases it insignificantly (though I personally doubt that increase in 10 times can be considered insignificant) it will still be more useful for UNDERSTANDING developers than all possible disadvantages of OOP.

The thing is that MQL5, if it contains OOP, will somehow contribute to the development of modular (unit) approach to programming, that isn't seen in MQL4 (except for libraries). This is due to the fact that it is convenient to place structures, classes or groups of them in separate files (modules) and use them when necessary.

Also, due to abstraction, encapsulation, inheritance and polymorphism, the use of classes will allow to debug the ready blocks (modules) and not thinking about their contents to use them in your own work.

Also, the use of OOP should increase the level and convenience of using external DLLs and other software tuning in trading systems.

Combined with the use of libraries, this will make developers' lives a dozen times easier and also greatly speed up the development of fairly complex EAs.

 
Integer:

What speed of operation are you referring to, the speed at which the programme runs or the speed at which it is written?

Both. The details about development speed are written above (of course, it all makes sense if you have some experience in developing and using classes)...
 
Interesting:

It does, it does, it does....

Who told you that? It's not true. Everything else is correct.

 
Integer:

Who told you that? It's not true. Everything else is correct.

I'll repeat - It increases, it increases, how much it increases. But it all depends on experience, imagination and crookedness of programmer's hands (in this very order)...

Once upon a time I was comparing the initialization speed of my EA, except for some minor details, the program code was the same (in MQL5 the migration library was used). And it turned out that MQL5 initialization was 2.5 times faster on average.

Of course, I know it's not an indicator, but I'm still confident that MQL5 speed is 10 times faster even now, using the right approach.

You can argue forever, but try implementing OnTrade() orOnChartEvent and everything will become clear. But besides these things there are a lot of other "goodies"...

PS

Of course, there are speed bugs in the strategy tester and indicators. But in time these shortcomings will be eliminated by developers of the terminal, or authors of trading Expert Advisors.

In addition, MQ stated more than once that the maximum speed of program code execution is not available yet (as far as I know still)...

 
Increases... Increases... All that's left is to sing it to the tune of a mantra with a bells in hand and dressed in a cassock. MQL5 is faster than MQL4, not because it supports objects.
 
Integer:
Increases... increases... ...you'd better sing it in a mantra with a bells in hand and put on a frock.

Integer:
MQL5 is faster than MQL4, not because it supports objects.
But still, in most cases, it's faster. In my opinion, it's not appropriate to compare MQL5 with MQL4 (or any other programming language) in terms of speed of working with objects.
 

Using the GetTickCount() function, I have tested similar Expert Advisors with and without OOP:

Test my_oop_ea ( with OOP )

RJ 0 Core 1 15:12:15 Test Time = 115203

EO 0 Core 1 15:12:15 EURUSD,H1: 6124935 ticks (3052 bars) generated within 115203 ms (total bars in history 9199)

RP 0 Core 1 15:12:15 Disconnected


My_First_EA test ( without OOP )

RH 0 Core 1 15:18:54 Test Time = 90578

CR 0 Core 1 15:18:54 EURUSD,H1: 6124935 ticks (3052 bars) generated within 90578 ms (total bars in history 9199)

OR 0 Core 1 15:18:54 Disconnected


The difference is small, but not in favor of OOP. And in case of optimization this difference is multiplied by the number of runs, if I understand correctly.

I have drawn conclusions for myself.

Also I compared the standard MACD Sample EA for MT5 (with OOP) and for MT4:

Macd Sample MT5

FO 0 Core 1 18:03:21 Test time = 126016

FD 0 Core 1 18:03:21 EURUSD,M1: 6124935 ticks (181129 bars) generated within 126016 ms (total bars in history 545615)


Macd Sample MT4

18:12:52 2010.06.30 23:59 MACD Sample EURUSD,M1: Time Tests = 64406

The results are amazing - MT5 and MQL with OOP are not only resource eaters but also time eaters.

 

When testing different MT4 and MT5 platforms, you cannot draw conclusions specifically about OOP. The differences in the results are 90% due to different system architecture.

This article has been completed using the above method. Besides, the code optimizer in MQL5 has been disabled for the time being - we are fine tuning it. When it is enabled, the results will immediately improve many times over.

Yesterday an article comparing the speed of MQL4 and MQL5 was published - I recommend you to read it:

MQL5 Analysis of Moving Averages Performance has been published:

Since the first simple moving average indicator was created, a lot of different indicators have appeared. Many of them are based on a similar principle or use certain ways of price series processing in their calculations. However, the question of calculation speed of such indicators and optimality of algorithms used in them often remains unanswered. This article describes all possible options for using moving averages, and makes a comparative analysis of each of them.

Author: Sergey

 


A function with another parameter is clearly slower. Is it really just because of the parameter?

Files:
test.mq5  2 kb