Tiki in real time - page 18

 
prostotrader:

While the debate is going on, I did another experiment.

I mean, during initialisation I time it by a microsecond,

and before each print, I drill the time again.

Ideally, it should be so

But very often it turns out so (log exposures):

But it doesn't fit with 4 seconds...

oh, they finally figured out how to time it, progress!)

s.s. as a confirmation that the time is not exactly written to disk I'll give you a simple test, between operations in the Test are done some calculations, taking on average 7 microseconds.

At the same time we see that with the same time in microseconds prints are output in tens + such operations, and prints are outputted every microsecond. I think it all makes sense.

ap: if you put the first print right before the second, then the delta is already 0-1, so the Print is the longest in this chain.

   for(int count=0;count<10000;count++) 
     { 
         ul=GetMicrosecondCount();         
         Print("MicrosecondCount ",ul);
         Test(); 
         ul_cur=GetMicrosecondCount(); 
         Print("MicrosecondCount ", ul_cur, " delta ",ul_cur-ul);
     }     



 
Aleksey Mavrin:

Oh, they've finally figured out how to time it, progress!)

What's the matter with you, sir? Don't you have anything better to do?

That's where it all started!

 
prostotrader:

Don't you, sir? Don't you have anything better to do?

This is where it all started!

Added by

Also, don't you know thatGetMicrosecondCount() has an error of up to 16 ms! :)

The function that gives microseconds, has an error of up to 16 milliseconds, i.e. the error is an order of magnitude higher than its name, well, well)) can you also confirm with a pruf?

 
Aleksey Mavrin:

A function that gives microseconds has an error of up to 16 milliseconds, i.e. an error that is an order of magnitude greater than its name, well, well)) can you also confirm with a pruff?

Got it wrong

 
prostotrader:

Wrong

Well, kudos to you for admitting the error straight away ;)

The lag of 4 seconds is most likely true at some point the terminal got confused, it seems to happen when antivirus starts scanning etc. cases.

And 4 seconds means that Print is 4 seconds later in the log cache, not that OnBook came 4 seconds later (although I think it's possible depending on how the computer is loaded at the moment)

s.w. as Print goes to the queue first and from there to the log.
 
Aleksey Mavrin:

Well, kudos to you for admitting the error straight away ;)

The 4 second lag is most likely true at some point the terminal got confused, it seems to happen when antivirus starts scanning etc. cases.

And 4 seconds exactly means that Print came 4 seconds later in the log cache, not that OnBook came 4 seconds later (although I think it's possible depending on how you load the computer at that moment)

s.w. as Print goes to the queue first and from there to the log.

Yeah, it's possible.

 
Aleksey Mavrin:

And 4 seconds means exactly that Print came 4 seconds later in the log cache, not that OnBook came 4 seconds later (although I guess it's possible depending on how the computer is loaded at the time)

s.w. Print goes to the queue first and from there to the log.

Well yeah, how about that?

One chart was running OnBook and the other OnTick.

//+------------------------------------------------------------------+
//|                                                   Ticks_test.mq5 |
//|                                      Copyright 2019 prostotrader |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019 prostotrader"
#property link      "https://www.mql5.com"
#property version   "1.00"
//---
bool is_book;
enum ENUM_BOOK_OR_TICK
{
        USE_BOOK,       // Use OnBookEvent
        USE_TICK        // Use OnTick
};

input ENUM_BOOK_OR_TICK Mode = USE_BOOK;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
  if(Mode == USE_BOOK) is_book = MarketBookAdd(Symbol());
  return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
  if(Mode == USE_BOOK)
  {
    if(is_book == true) MarketBookRelease(Symbol());
  }  
}
//+------------------------------------------------------------------+
//| BookEvent function                                               |
//+------------------------------------------------------------------+
void OnBookEvent(const string &symbol)
{
  if((Symbol() != symbol) || (Mode != USE_BOOK)) return;
  Print(__FUNCTION__, "; Time: ", GetTickCount(), " ms");
}
void OnTick()
{
  if(Mode != USE_TICK) return;
  Print(__FUNCTION__, "; Time: ", GetTickCount(), " ms");
}
//+------------------------------------------------------------------+


56 ms difference between OnTick and OnBook

and the same difference in print :)

2020.02.04 22:37:48.212 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205482644 ms
2020.02.04 22:37:49.268  Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 20548369 0 ms

2020.02.04 22:37:50.354 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205484782 ms
2020.02.04 22:37:50.354 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205484782 ms

2020.02.04 22:37:51.064 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205485484 ms
2020.02.04 22:37:51.064 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205485484 ms

2020.02.04 22:37:52.833 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205487262 ms
2020.02.04 22:37:52.833 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205487262 ms

2020.02.04 22:38:01.932 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205496357 ms
2020.02.04 22:38:01.932 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205496357 ms

2020.02.04 22:38:05.310 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205499742 ms
2020.02.04 22:38:05.310 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205499742 ms

2020.02.04 22:38:07.706 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205502129 ms
2020.02.04 22:38:07.706 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205502129 ms

2020.02.04 22:38:09.426 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205503845 ms
2020.02.04 22:38:09.426 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205503845 ms

2020.02.04 22:38:10.035 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205504453 ms
2020.02.04 22:38:10.035 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205504453 ms

2020.02.04 22:38:14.225 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205508650 ms
2020.02.04 22:38:14.225 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205508650 ms

2020.02.04 22:38:14.252 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205508681 ms
2020.02.04 22:38:14.252 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205508681 ms

2020.02.04 22:38:14.593 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205509024 ms
2020.02.04 22:38:14.593 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205509024 ms

2020.02.04 22:38:15.105 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205509523 ms
2020.02.04 22:38:15.105 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205509523 ms

2020.02.04 22:38:15.584 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205510007 ms
2020.02.04 22:38:16.226 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205510647 ms

2020.02.04 22:38:16.232 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205510662 ms
2020.02.04 22:38:16.232 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205510662 ms

2020.02.04 22:38:21.476 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205515904 ms
2020.02.04 22:38:21.477 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205515904 ms

2020.02.04 22:38:22.403 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205516824 ms
2020.02.04 22:38:22.404 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205516824 ms

2020.02.04 22:38:23.582 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205518010 ms
2020.02.04 22:38:23.583 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205518010 ms

2020.02.04 22:38:24.707 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205519133 ms
2020.02.04 22:38:24.708 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205519133 ms

2020.02.04 22:38:30.962 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205525389 ms
2020.02.04 22:38:30.962 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205525389 ms

2020.02.04 22:38:31.188 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205525607 ms
2020.02.04 22:38:31.189 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205525607 ms

2020.02.04 22:38:31.989 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205526418 ms
2020.02.04 22:38:31.989 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205526418 ms

2020.02.04 22:38:32.048 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205526481 ms
2020.02.04 22:38:32.048 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205526481 ms

2020.02.04 22:38:32.140 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205526559 ms
2020.02.04 22:38:32.140 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205526559 ms

2020.02.04 22:38:32.153 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205526574 ms
2020.02.04 22:38:32.153 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205526574 ms

2020.02.04 22:38:32.589 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205527011 ms
2020.02.04 22:38:32.590 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205527011 ms

2020.02.04 22:38:39.930 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205534359 ms
2020.02.04 22:38:39.931 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205534359 ms

2020.02.04 22:38:40.009 Ticks_test_2 (GOLD-3.20,M1)     OnTick; Time: 205534437 ms
2020.02.04 22:38:40.009 Ticks_test_2 (GOLD-3.20,M1)     OnBookEvent; Time: 205534437 ms
 
prostotrader:

Right, how about this?

One chart was running OnBook and the other OnTick


56 ms difference between OnTick and OnBook

And the same difference in print :)

Again, I'm not exactly sure, as I'm sleepy and doubts are the lot of the experienced and wise).

But I think it's just elementary thatSymbol() eats time )))

so true test - check - I'm too lazy)

it's ulong glob. perm.

void OnBookEvent(const string &symbol)
{
ul=GetTickCount();
  if((Symbol() != symbol) || (Mode != USE_BOOK)) return;
  Print(__FUNCTION__, "; Time: ", ul, " ms");
}
void OnTick()
{
ul=GetTickCount();
  if(Mode != USE_TICK) return;
  Print(__FUNCTION__, "; Time: ", ul, " ms");
}
//+------------------------------------------------------------------+
 
Aleksey Mavrin:

Again, I'm not sure, because I'm sleepy and doubts are the lot of the experienced and the wise).

But I think it's just elementary thatSymbol() chews up time )))

so true test - check - I'm too lazy)

it's ulong glob. perm.

:), good night

 
Aleksey Mavrin:

Again, I'm not sure, because I'm sleepy and doubts are the lot of the experienced and the wise).

But I think it's just elementary thatSymbol() chews up time )))

so true test - check - I'm too lazy)

it's ulong glob. perm.

string gSymbol;
int OnInit()
{
gSymbol = Symbol(); 
return 0;
}

void OnBookEvent(const string &symbol)
{
ul=GetTickCount();
  if((Symbol() != symbol) || (Mode != USE_BOOK)) return;
  Print(__FUNCTION__, "; Time: ", ul, " ms");
}
void OnTick()
{
ul=GetTickCount();
  if((Symbol() != gSymbol) || (Mode != USE_TICK)) return;  // можно попробовать привести оба обработчика к одинаковому коду
  Print(__FUNCTION__, "; Time: ", ul, " ms");
}
//+------------------------------------------------------------------+

Alternatively, to eliminate concerns that Symbol() eats time, let both handlers "feed" equally.