Discussion of article "Statistical Distributions in MQL5 - taking the best of R" - page 5

 
Renat Fatkhullin:
  1. Presence of MQL5 libraries in the source code, which allows you to natively inline their code directly into the place of call and maximise the use of const environment of the called place.

Will many standard functions also be included in libraries for inlining?

 
Renat Fatkhullin:

That's not serious.

Under wyne, and even 32 bits. An old compiler similar to MT4 is used for 32 bits of MT5. It is a couple of tens of times slower than the 64-bit code, which is created by a new compiler specially for the 64-bit version of MT5. We have published a report comparing the speed of 32 and 64 bit MQL5 programmes.

Each MQL5 programme actually contains two copies of the compiled code: 32-bit for old systems for the sake of compatibility and 64-bit for new ones.

We have completely abandoned the development of 32-bit compilers as it makes no sense and has no future.

That's why you should use only 64-bit versions of MetaTrader 5 if you want to get the maximum performance.


By the way, information for those who sit on MT4 - there too the speed of MQL4 code execution is a couple of tens of times slower than in 64-bit MetaTrader 5.

Unexpectedly... For me, this is a really serious reason to finally reconsider my habits and switch to MT5. Previously, I did not see much sense in it....
 
fxsaber:

Will many standard functions be put into libraries for inlining as well?

Exactly.

In the next couple of builds we will come to it. We will add function sources to programs on the fly during compilation, which will allow the optimiser to work to its full potential.

It is crucial for us to minimise the number of calls to the platform kernel.

 
Реter Konow:
Unexpectedly... For me it is really a serious reason to finally reconsider my habits and switch to MT5. Previously I didn't see much sense in it....

If you dig deep into the latency of MT4 and MT5 internal processes, including trading, you will run away from MT4. There is an abyss in the quality and tidiness of processes.

We are so fanatical about MT5 performance and optimisation for a reason. It is a huge technological advantage.

 
Renat Fatkhullin:

R took the minimum time over many starts, not the first start and maximum time.

So no, "cold start" doesn't explain it here. And even in conditions when all library code is in DLL. There is practically nothing to warm up.

But what does explain it:

  1. Absence of overhead on dynamic objects as in R due to work with purely typed double data
  2. A terribly efficient compiler in MQL5. It is really scary to look at the resulting asm code.
  3. Presence of MQL5 libraries in the source code, which allows you to natively inline their code directly into the place of call and maximally use const environment of the called place.

    This is where the compiler has a lot of room compared to actually unoptimised implementations in DLLs, which have no chance to learn the environment and adjust to it.

What is being measured here? It reminds me of C++ vs Lisp holivars - it's just one-to-one, except that one of the "comparators" is almost ++ and the other is Schema :-)) They are just fundamentally different things....
 
Renat Fatkhullin:

If you dig deep into the latency of MT4 and MT5 internal processes, including trading, you will run away from MT4. There is an abyss in the quality and tidiness of processes.

We are so fanatical about MT5 performance and optimisation for a reason. It is a huge technological advantage.

Now I will know. Of course, porting all the code will not be easy even with sufficient language compatibility, but I believe the result will be worth it. I'm always oriented to greater efficiency and the question of performance and speed difference has always been of great interest to me. If I knew about this difference earlier, I would have forgotten about the less fast platform long ago. Thanks for the information.
 
Maxim Kuznetsov:
What is being measured here ? It reminds me of C++ vs Lisp holivars - just the same, except that one "compares" almost ++ and the other one is Schema overgrown :-) They are just fundamentally different things.....

This is just pure proof in practice and in theory of the fallacy of the position expressed by some traders in the topic https://www.mql5.com/ru/forum/96176/page10 (there was a mention somewhere):

  • in R all libraries are optimised and as fast as possible
  • there are many optimisations in R, including Intel Threading Building Blocks, etc.


It turned out that this is not true. In the simplest function, it turned out to be a drain and MQL5 is more efficient. Moreover, I have substantiated why it is faster theoretically. In addition to the practical results.

Используете ли вы CExpert при создании роботов?
Используете ли вы CExpert при создании роботов?
  • www.mql5.com
Да Нет, пишу класс робота с нуля Нет, у меня есть свой базовый класс робота Нет, я не использую ООП Хочу посмотреть результат...
 
Renat Fatkhullin:

If you dig deep into the latency of MT4 and MT5 internal processes, including trading, you will run away from MT4. There is an abyss in the quality and tidiness of processes.

Trading is somehow forgotten

Forum on trading, automated trading systems and testing trading strategies

Errors, bugs, questions

fxsaber, 2016.10.09 09:39 pm

MT5-OrderSend is NOT fully synchronised - there is no synchronisation with the trading environment. This means that the history readings do not correspond to the real state of affairs.

Any timeout is out of the question. There is no reliable solution to the problem, because synchronisation issues have to be dealt with at the terminal level, not at the server level.

In fact, MT5-users have faced what MT4 bridge developers have faced.

If an OrderSend is sent, one should REMEMBER (here is a potential vulnerability) that it is done. Then ignore the current history (trading environment) until the corresponding message arrives in OnTrade. Once it arrives, the NOTHING needs to be FORGOTTEN.

When there is no FORGOTTEN data, you can trust the history as in MT4.

MT4-OrderSend is FULLY synchronised.

Yes and with the rest, much simpler, as it turns out, problems

 
fxsaber:

Somehow trading is forgotten

You are confusing asynchronous processes with the desire to see synchronisation.

The task of OrderSend is to place a request and receive confirmation as quickly as possible. And the system copes with it perfectly.

But to get a completed transaction/deal, put it in the history and then give it to you under request - this is another process and it has no right to slow down the work of OrderSend.

That's why everything is right - you execute the transaction quickly, and then in a millisecond (actually earlier) in the neighbouring packet you get a ticket update and work with it.


And with the rest, much simpler, as it turned out, there are problems as well

Writing a compiler and especially implementing evil C++ templates are simple things????

Anyway, many thanks for A100's patience - he was very helpful in catching bugs.


But this is offtopic, if you want to discuss these questions, do it in native threads. Here about R.
 
Comments not related to this thread have been moved to "How to properly work in MT5 with OrderSend".