MT5 and speed in action - page 53

 
Roman:

As it is, I'm pinging the server, at a certain frequency in while with no delay.

More than 16 ms? What kind of server? What is the point of pinging so frequently?

 
fxsaber:

Sent this to the PM.

If you press CTRL+BREAK while compiling at 22%, ME hangs.

 
Andrey Khatimlianskii:

More than 16 ms? What kind of server is it? What is the point of such frequent pings?

The point is not 16ms, it's a no-delay loop.
It reads a socket and pings heartbeat.

 
Roman:

The point is not 16ms, it's a no-delay loop.
It reads a socket and pings heartbeat.

Got it, reading a socket.

Then why slip at all? Or is reading socket without delay a bad thing?

I can't understand the point of heartbeat at this rate (

 
Andrey Khatimlianskii:

Got it, reading a socket.

Why slip at all then? Or is reading socket without delay a bad thing?

I can't understand the point of heartbeat at this rate (

So what's a macro for?
Socket is read in loop without delay, andheartbeat is executed with defined frequency in the same loop without delay.
Slip has nothing to do with it, I wrote a slip as a part of it, it may come in handy.
The point of the macro is to set frequency of some code execution in the loop without any delay.
Not necessarilyheartbeat. You can make any macros with different
frequency and they will be executed differently in the loop without any delay.
For example, Nikolai wrote a class for OnTimer. https://www.mql5.com/ru/code/31306
And here for the loop, which can go down to microseconds.

Multi Timer
Multi Timer
  • www.mql5.com
Данная библиотека Вам пригодится, когда Вам необходимы несколько таймеров с независимой обработкой и неконфликтующие между собой. Для работы с данной библиотекой важно запомнить следующие правила: В теле вашей программы не должно быть функции OnTimer , т.к. эта функция уже присутствует в файле Timer.mhq Не надо создавать никаких экземпляров...
 
Roman:

So the macro is for what?
Socket is read in a loop without delay, andheartbeat is executed at a certain frequency in the same loop without delay.
Slip has nothing to do with it, I wrote that I wrote a slip as well, it may come in handy.
The point of the macro is to set frequency of some code execution in the loop without any delay.
Not necessarilyheartbeat. You can make any macros with different
frequency and they will be executed differently in the loop without any delay.
For example, Nikolai wrote a class for OnTimer. https://www.mql5.com/ru/code/31306
And here for the loop, which can go down to microseconds.

So that's what it was all about:

while ( true )
{
   static ulong prev = 0;
   if ( GetMicrosecondsCount() - prev >= InpPause_msc )
   {
     prev = GetMicrosecondsCount();
     // do something
   }

?


Then it's still not clear what the microsecond slip is for. Apparently, it's just "extra". Well, let it be )

 
Andrey Khatimlianskii:

So that's what it was all about:

?

Then it's still not clear why the microsecond slip. Apparently, it's just "extra". Well, let it be )

Well, you can write it that way too. I just did it through a switch and a macro.
In your example there are two calls to GetMicrosecondsCount while in mine there is one.
Yes, so the microsecond slip may come in handy in this loop.
Just the fact that microsecond slip is possible.

 
Andrey Khatimlianskii:

Got it, reading a socket.

Why slip at all then? Or is reading socket without delay a bad thing?

I can't understand the meaning of heartbeat with such frequency (

In this case slip is harmful at all. Because it gives priority to another thread and slows down your own thread.

 
Roman:

Well, you could write it that way. I just did it with switch and macro.
And in your example there are two calls to GetMicrosecondsCount, in mine there is one.
And yes, slip as well, if microsecond slip is of any use in this loop.
Just the very fact that a microsecond slip is possible.

Not possible

 
Slava:

Impossible

OK, let me rephrase. Within mql roughly possible, depending on processor clock speed.
What about PWM? -A pulse signal of constant frequency and variable duty cycle.
Doesn't it set a constant?