MT5 and speed in action - page 89

 
Maybe just run a couple of tests and the questions will go away?
 
traveller00:
Maybe just run a couple of tests and the questions will go away?

Maybe. I wish I had more time to do the tests myself :(

 
traveller00:
Maybe just run a couple of tests and the questions will go away?

The tests only show a difference the first time you start.

 
Slava:

Symbol(), _Symbol entries are equivalent to NULL (where NULL is allowed instead of symbol name).

In this case, there is no extra check for the existence of the current symbol, the presence of the current symbol in the Market Watch and unnecessary call properties of the current symbol, as properties of the current character is cached

That is, if a normal string parameter is specified instead of Symbol(), _Symbol or NULL, then checks for the full program and more property calls

Question:

   string symbol=_Symbol;
   SymbolInfoInteger(symbol,...)
   SymbolInfoInteger(NULL,...)

- behavior of SymbolInfoXXX calls in these two cases, will they differ by more than a check?

symbol==_Symbol

?

 
traveller00:

By the way, from today's fresh logs from the latest release version of MT5:

It was 3 EAs hovering on 1 symbol, each on its own chart. And the request goes on every tick. Such spikes are of course infrequent, but in fact 1 request for new ticks coming from the last tick was executed 700 ms.

I've been monitoring for about 12 hours, but I can already see the lags crossing all limits.

Time[Main.mqh 162 in ProcessTicks: CopyTicksRange(_Symbol,OldTicks,COPY_TICKS_INFO,LastTickParsed.time_msc)] = 8589203 mcs.

3 EAs, each on its own chart, all on 1 symbol, are requesting old ticks from the previous tick via CopyTicksRange. And the lag is almost 9 seconds. And it seems that this is not the limit. Most likely the tick store is a shared resource to which access is synchronised, but even with very awful synchronisation there shouldn't be such times.

Some would say it's a one-off glitch. In those 12 hours of monitoring unfortunately there have been over a hundred 1 second exits. And these no longer look like one-off bursts. It looks like there were often multiple ticks coming in at the same time, which is what is causing these spikes.

Even if we close our eyes to the fact that 3 EAs fought over a common resource, let's look at the other monitoring:

ProcessTicks: CopyTicksRange(_Symbol,OldTicks,COPY_TICKS_INFO,LastTickParsed.time_msc)] = 1401285 mcs.

There was only 1 Expert Advisor on the symbol. And still a second and a half. It wasn't the only one, there were other EAs on other symbols, but isn't it multi-threaded? Or ticks for different symbols can still slow each other down?

This is basic functionality for basic EAs. The platform is positioned as an algorithmic trading platform. That said, the basic functionality raises strong questions. A big request to look at it again. I'm almost sure there is room for improvement somewhere. Or would be very grateful to be able to get the last ticks since the function has been called, as suggested here

Forum on trading, automated trading systems and testing trading strategies

MT5 and Speed in Action

fxsaber, 2021.03.01 07:28

Please think about such a feature.

int SymbolInfoTicks( const string Symb, MqlTick &Ticks[] ); // Возвращает свежие тики (не более сотни), пришедшие с предыдущего вызова этой функции.


The problem of getting NEW ticks without skips is now solved only through CopyTicks*. It's a very cumbersome mechanism for this widespread task. It's like shooting birds with a cannon.

Hence brakes, retention of huge caches, etc.

 

Minimized the number of calls to SymbolInfoTick and CopyTicksRange:

  • SymbolInfoTick snapshot - not called more often than once every 100µs.
  • The CopyTicksRange for fresh ticks is only called if, indeed, a new tick has arrived in the Market Watch.


The terminal and the machine (swap file disabled) with this load.


As a result, it was possible to significantly reduce the number of lag messages (less calls were made) of the regular functions.


Log in 50 minutes:

2021.03.05 19:31:45.429 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 154 mcs.
2021.03.05 19:32:58.939 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 161 mcs.
2021.03.05 19:33:01.583 ::SymbolInfoTick(_Symbol,Tick)] = 158 mcs.
2021.03.05 19:36:01.682 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 143 mcs.
2021.03.05 19:36:31.229 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 234 mcs.
2021.03.05 19:36:31.229 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 913 mcs.
2021.03.05 19:39:08.716 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 139 mcs.
2021.03.05 19:39:30.994 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 315 mcs.
2021.03.05 19:39:32.858 ::CopyTicks(_Symbol,Tick,COPY_TICKS_ALL,0,1)] = 114 mcs.
2021.03.05 19:40:41.437 ::CopyTicks(_Symbol,Tick,COPY_TICKS_ALL,0,1)] = 101 mcs.
2021.03.05 19:42:26.104 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 116 mcs.
2021.03.05 19:42:28.849 ::SymbolInfoTick(_Symbol,Tick)] = 109 mcs.
2021.03.05 19:43:10.977 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 481 mcs.
2021.03.05 19:43:53.945 ::SymbolInfoTick(_Symbol,Tick)] = 130 mcs.
2021.03.05 19:49:20.352 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 101 mcs.
2021.03.05 19:51:31.242 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 102 mcs.
2021.03.05 19:51:44.986 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 107 mcs.
2021.03.05 19:52:05.590 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 219 mcs.
2021.03.05 19:53:56.013 ::SymbolInfoTick(_Symbol,Tick)] = 236 mcs.
2021.03.05 19:55:41.453 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 105 mcs.
2021.03.05 19:55:47.109 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 148 mcs.
2021.03.05 19:55:47.110 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 265 mcs.
2021.03.05 19:59:26.011 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 186 mcs.
2021.03.05 20:00:01.569 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 117 mcs.
2021.03.05 20:01:19.704 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 109 mcs.
2021.03.05 20:02:07.285 ::SymbolInfoTick(_Symbol,Tick)] = 177 mcs.
2021.03.05 20:02:07.286 ::SymbolInfoTick(_Symbol,Tick)] = 198 mcs.
2021.03.05 20:02:07.286 ::SymbolInfoTick(_Symbol,Tick)] = 202 mcs.
2021.03.05 20:04:40.170 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 364 mcs.
2021.03.05 20:04:45.905 ::SymbolInfoTick(_Symbol,Tick)] = 143 mcs.
2021.03.05 20:04:45.906 ::SymbolInfoTick(_Symbol,Tick)] = 158 mcs.
2021.03.05 20:04:45.907 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 504 mcs.
2021.03.05 20:04:48.259 ::SymbolInfoTick(_Symbol,Tick)] = 104 mcs.
2021.03.05 20:04:54.727 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 104 mcs.
2021.03.05 20:05:39.642 ::CopyTicks(_Symbol,Tick,COPY_TICKS_ALL,0,1)] = 101 mcs.
2021.03.05 20:07:40.189 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 101 mcs.
2021.03.05 20:09:21.844 ::SymbolInfoTick(_Symbol,Tick)] = 115 mcs.
2021.03.05 20:09:32.422 ::SymbolInfoTick(_Symbol,Tick)] = 107 mcs.
2021.03.05 20:10:02.423 ::SymbolInfoTick(_Symbol,Tick)] = 128 mcs.
2021.03.05 20:15:48.838 ::CopyTicks(_Symbol,Tick,COPY_TICKS_ALL,0,1)] = 149 mcs.
2021.03.05 20:16:36.001 ::SymbolInfoTick(_Symbol,Tick)] = 105 mcs.
2021.03.05 20:17:51.499 ::CopyTicks(_Symbol,Tick,COPY_TICKS_ALL,0,1)] = 480 mcs.
2021.03.05 20:17:51.638 ::SymbolInfoTick(_Symbol,Tick)] = 342 mcs.
2021.03.05 20:17:52.802 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 429 mcs.
2021.03.05 20:17:53.340 ::SymbolInfoTick(_Symbol,Tick)] = 142 mcs.
2021.03.05 20:19:21.512 ::SymbolInfoTick(_Symbol,Tick)] = 122 mcs.
2021.03.05 20:20:35.836 ::CopyTicks(_Symbol,Tick,COPY_TICKS_ALL,0,1)] = 116 mcs.


Doesn't seem too bad. There were no trade transactions. How about them, I'll see.


HOWEVER, the highlighted fragment shows that three EAs (different characters) got lagged almost simultaneously. I.e. the lag is universal for the Terminal.

 
Slava:

Symbol(), _Symbol entries are equivalent to NULL (where NULL is allowed instead of symbol name).

In this case, there is no extra check for the existence of the current symbol, the presence of the current symbol in the Market Watch and unnecessary call properties of the current symbol, as properties of the current node are cached

That is, if you specify a simple string parameter instead of Symbol(), _Symbol or NULL, then there are checks for the full program and more request properties

Please explain again, because different interpretations of your words from forum users.

 

In Terminal with one EA/chart/symbol.


2021.03.05 23:02:02.860 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 189 mcs.
2021.03.05 23:02:24.152 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 339 mcs.
2021.03.05 23:02:53.540 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 915 mcs.
2021.03.05 23:05:35.325 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 223 mcs.
2021.03.05 23:05:41.398 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 245 mcs.
2021.03.05 23:05:44.585 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 376 mcs.
2021.03.05 23:06:35.210 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 173 mcs.
2021.03.05 23:07:38.298 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 290 mcs.
2021.03.05 23:08:50.342 ::CopyTicksRange(_Symbol,Ticks,COPY_TICKS_INFO,From)] = 102 mcs.
2021.03.05 23:14:58.216 ::SymbolInfoTick(_Symbol,Tick)] = 447 mcs.

Such a log in 15 minutes. Seems to be a matter of slow Windows after all. In this case it is.

2021.03.05 23:49:20.792 Terminal        MetaTrader 5 x64 build 2815 started for MetaQuotes Software Corp.
2021.03.05 23:49:20.792 Terminal        Windows Server 2019 build 17763, Intel Core i7-7700 K  @ 4.20 GHz, 17 / 31 Gb memory, 3698 / 3725 Gb disk, IE 11, RDP, UAC, GMT+2
 

A clear example of the brakes that Market Watch causes.

Look at the values in the Processor column (second from right).

 
To the Server's lag is added the Terminal's lag.

Forum on trading, automated trading systems and testing trading strategies

Indicators: Ping

fxsaber, 2021.03.12 10:56

Just remembered this great indicator.

It is a picture from the machine with zero ping. It turns out that the terminal's internal lag averages ~2ms. It bounces between 0-9 ms.


For example, the server received two ticks: first one, then the second one after 10 ms. So, in Terminal the second tick can be received not in 10 ms after the first one, but in 10-19 ms. On average, it is 12 ms later.

If you trade from the market (market marts or pending orders at the current price), it will be especially difficult to manage. It's hard to say whether the Developers will be able to improve anything here.

Looked at the Moscow exchange, the situation there is similar. In fact, trading through the MT5 algo, you are almost guaranteed to be at the end of the execution queue, not having time to pick up the good stuff, unfortunately.

Акцептирование SL/TP-ордеров
Акцептирование SL/TP-ордеров
  • 2020.11.24
  • www.mql5.com
В этой ветке пойдет речь об ордерах, которые создаются в результате срабатывания SL/TP-уровней открытых позиций...