Features of the mql5 language, subtleties and tricks - page 95

 
Slava:

Are you sure you read the whole question?

...between two calls to GetMicrosecondsCount...

Well, this is what I'm talking about. The first call happens before the synchronization, and the second call happens after the synchronization. The difference will be equal: the actual number of microseconds + correction of synchronization.

 
Alexey Navoykov:

Well, that's what I'm talking about. The first call occurs before synchronization, and the second call occurs after synchronization. The difference will be equal: the actual number of microseconds + correction of synchronization.

Now tell me the probability of time correction between two calls to GetMicrofsecondsCount?

If you're really measuring microseconds, then the probability is almost 0.

Do you measure microseconds at intervals of seconds or more? Why do you measure microseconds? Spherocon in vacuum?

 
Alexey Navoykov:

You're wrong. I specifically cited the code here using WinApi. Run it, change the clock in the process, and look at the result.

It is not very clear how to conduct any dialogue with you, if your arguments are based on speculations. And you don't even consider it necessary to read the course of discussion of the topic.

You're the one who has no idea about the problem you raised.

Like I said, an unexpected time change will kill your code, which is tied to exact time control regardless of functions you use.
 
Slava:

Now tell me the probability of time correction between two calls to GetMicrofsecondsCount?

If you really measure microseconds, the probability is almost 0.

And you measure microseconds at intervals of seconds or more? Why? A spherocon in a vacuum?

I already answered, this probability depends on the synchronization period. The shorter it is, the more often we will get a shift, i.e. the higher the probability. And also on the distance between neighboring measurements. The longer it is, the more often we will hit the shift. I.e. the probability is calculated based on these two parameters, not just a finger in the sky.

And why do you write at once about second intervals? And millisecond intervals? For example everything less than 16 ms can be measured only by this function. And even 16-30 milliseconds must also be measured by this function, otherwise the error will be too big.

If it seems to you that these are trifles and they can be ignored, then it's purely your personal opinion. Earlier here we talked about standard system function QueryPerformanceCounter, which works properly, without any shifts. It probably was invented for a reason. And by the way, Renat here said for some reason:

That's how microseconds are counted here.

Although that's not how it's counted. You were talking about the QueryPerformanceCounter.

 
Renat Fatkhullin:
You're the one who has no idea about the problem you've raised.

Like I said, an unexpected time change will kill code tied to precise time control regardless of the functions used.

QueryPerformanceCounter doesn't have any time change, what do you mean? Did you run the code I gave you the link to?

 

After checking the MQL5 code's execution machine, it turned out that the hybrid GetMicrosecondCount measurement scheme was working for us:

  • for Windows 8 and higher, the slightly faster GetSystemTimePreciseAsFileTime function dependent on system time was used
  • for the other cases, the GetPerformanceFrequency + QueryPerformanceCounter
  • in both cases, GetMicrosecondCount was performing its function of fetching microseconds from the program's start

This code appeared because of an attempt to reduce the system overhead on the time measurement call. One of the developers overdid it.

We, personally, and Slava were sure that a pure QueryPerformanceCounter was working. And there was such a code. But they made a mistake because of the hybrid model.

Now pure QueryPerformanceFrequency + QueryPerformanceCounter will work.

Bottom line: yes, we screwed up both the implementation of the GetMicrosecondCount function and protection of its behavior.

Slava and I apologize!
 
Comments not related to this topic have been moved to "Bugs, bugs, questions".
 
Renat Fatkhullin:

A reminder about the use of "should" phrases either explicitly or implicitly. The use of "metaquotes should" instead of "please consider" is now unacceptable.

Please consider the assumption that, more often than not, reading between the lines has nothing to do with what the interlocutor writes.

Real bug reports with forum help and pouncing on MQ are incompatible things. It's hard to imagine a person who constantly shifts into a hater and back again.

 
MT5 itself measures long time intervals throughGetMicrosecondCount
IS      0       13:32:55.239    Trades  '11391209': accepted exchange buy 1.00 AFKS at market
DM      0       13:33:07.896    Trades  '11391209': deal #265475900 buy 1.00 AFKS at 9.095 done (based on order #284425784)
OD      0       13:33:07.898    Trades  '11391209': order #284425784 buy 1.00 / 1.00 AFKS at 9.095 done in 12757.608 ms
 

Friends, can you tell who to ask for advice - I want to understand how you can work on the price differences for the same product on different exchanges - I am new to this business, I want to understand. I would be grateful for any advice - maybe you need to write in another thread?

I have the ability to access multiple exchanges abroad, but do not understand how it all works

Reason: