MT5 and speed in action - page 29

 
Andrey Khatimlianskii:

Identify a break in communication

I don't know how to do this.

 
fxsaber:

I don't know how to do it.

What makes you think they happen and OnTrade gets lost? From the documentation?

 
Andrey Khatimlianskii:

What makes you think they happen and OnTrade gets lost? From the documentation?

Because Relogin resets the historical cache, which (I assume) is doped through the OnTrade mechanism.

 
fxsaber:

Not sure how to do this.

Without getting out of MT5 intertiki time, if possible. And with trading operations in relation to the order in the DC without in-house help, I can't think of anything.

 
Valeriy Yastremskiy:

Not getting out of MT5 intertitle time, if possible. And with trading operations in relation to the order in the DC without in-house help, I can't think of anything.

I don't get it.

 
fxsaber:

I don't get it.

Yes, something is wrong. The inter-tick time is only for missing ticks due to a break in communication. And in terms of queries and correctness of responses on orders, trades and position states, if the response is missed or changed due to communication failure and lags because of this, there seems to be no cheap solutions. Re-querying on the next tick is not always an option.

The solution for me would be an internal function to track the status of trades/positions with respect to orders to open, modify, partially close, and fully close a position. The request for tracking the result could be set in the order itself. And get the result on the current tick and not on the next one.

 
fxsaber:

Can you tell me what to do so that I don't have to deal with this while trading?

2020.09.15 22:17:04.633 Alert: Time[NewTicks.mqh 33: ::SymbolInfoTick(_Symbol,Tick)] = 13 ms.
2020.09.15 22:17:04.638 Alert: Time[NewTicks.mqh 33: ::SymbolInfoTick(_Symbol,Tick)] = 18 ms.
2020.09.15 22:17:04.640 Alert: Time[NewTicks.mqh 33: ::SymbolInfoTick(_Symbol,Tick)] = 20 ms.

Judging by the time of logging, everything happened in 7ms.

If you want to have a constructive discussion, give us the complete test conditions (server, account type, number of selected symbols, number of EAs, etc.).


The SymbolInfoTick runtime measurement code:

void OnTick()
  {
   MqlTick Tick;
//---
   ulong start,end,max_time=0,avr_time=0;
   int   count=1000;
   for(int i=0; i<count; i++)
     {
      start=GetMicrosecondCount();
      SymbolInfoTick(_Symbol, Tick);
      end=GetMicrosecondCount()-start;
      //---
      if(end>max_time)
         max_time=end;
      avr_time+=end;
     }
   Print("SymbolInfoTick max time: ",DoubleToString(max_time/1000.0,3)," ms; avr time: ",DoubleToString(avr_time/1000.0/count,3)," ms; ",count," iterations");
  }

On MetaQuotes-Demo server (20 symbols selected, Netting, 4 open positions):

2020.09.16 12:34:22.429 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.017 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:34:27.148 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.022 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:34:27.456 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.002 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:34:27.751 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.021 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:34:28.145 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.003 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:34:28.652 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.002 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:34:30.051 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.020 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:34:30.259 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.019 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:34:30.861 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.019 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:34:31.159 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.020 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:34:32.376 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.002 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:34:32.658 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.017 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:34:34.867 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.017 ms; avr time: 0.000 ms; 1000 iterations

131 symbols selected, 10 open positions:

2020.09.16 12:44:50.554 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.003 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:44:52.337 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.019 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:44:54.960 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.019 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:44:55.587 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.020 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:44:55.863 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.016 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:44:56.187 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.002 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:44:56.958 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.018 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:44:59.989 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.003 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:45:00.298 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.021 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:45:07.609 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.024 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:45:07.891 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.017 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:45:08.790 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.019 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:45:09.617 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.019 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:45:09.933 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.002 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:45:11.841 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.002 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:45:13.416 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.022 ms; avr time: 0.000 ms; 1000 iterations
2020.09.16 12:45:13.709 SymbolInfoTick (EURUSD,H1)      SymbolInfoTick max time: 0.017 ms; avr time: 0.000 ms; 1000 iterations
Windows 10 build 18363, Intel Xeon  E5-2630 v4 @ 2.20 GHz, 52 / 63 Gb memory
Совершение сделок - Торговые операции - Справка по MetaTrader 5
Совершение сделок - Торговые операции - Справка по MetaTrader 5
  • www.metatrader5.com
Торговая деятельность в платформе связана с формированием и отсылкой рыночных и отложенных ордеров для исполнения брокером, а также с управлением текущими позициями путем их модификации или закрытия. Платформа позволяет удобно просматривать торговую историю на счете, настраивать оповещения о событиях на рынке и многое другое. Открытие позиций...
 
Anton:

Judging by the time of the log entries, it all happened in 7ms.

That's three different EAs.

If you want constructive discussion, then give all test conditions in full (server, account type, number of selected symbols, number of EAs, etc.).

Real account, RannForex-Server, 16 symbols, M1 chart open on each (5000 max bars), on each one an EA is running, which accesses only its own symbol.

There can be about 50 positions and the same number of orders at a time. There are no indicators, and only CopyTicksRange (fresh ticks) and SymbolInfoTick are used to get the prices. There is no reference to bars.

 
fxsaber:

These are three different EAs given out.

Real account, RannForex-Server, 16 symbols, M1 chart open on each (5000 max bars), on each one an EA is running which only refers to its symbol.

There may be about 50 positions and the same number of orders at a time.

If I understand correctly, there's not an EA there, but a stress tester on each symbol. This changes things completely. And it shows the hiding of initial conditions.

That is, 16 threads on an 8(4+HT) processor (+N worker terminal threads in parallel) non-stop and without delays break into one synchronized symbol database object. Read/Write locks are mixed up because there is constant tick writing.

Usually in such a profile, depending on steepness of the processor and its mastering of threads, each thread can spend from 60% to 80% of time waiting.

And this is regardless of task type.

 
Renat Fatkhullin:

If I understood correctly, there is not an EA there, but a stress tester on each symbol.

Wrongly understood. Each EA is purely trading (in the Tester by real ticks does not slow down) and does not depend on others. All trading logic is executed only in OnTick, no spamming of trading orders, no recursion, no globalization and no resources.

OnTrade*, OnBook are not used. Second timer and OnChartEvent for the case when certain keys are pressed.


I am sure that proper implementation (by you or me) of snapshots will greatly reduce the number of calls of regular environment functions. Correspondingly, lags will be drastically reduced.

I never thought it would come to snapshot tricks. I'm studying the question, as standard MT5-advisor implementation is lame, unfortunately.