MT5 and speed in action - page 3

 
fxsaber:

Empty Terminal 2460.


ZS Run on empty account.


Seems the speed is heavily influenced by the number of trades, not orders.

It's possible. Will definitely check it out.

At even a frightening 20000ms / 100000 cycles it's a far cry from 5-30ms per call.

 

I don't understand how it works.

- I'm getting a little bit of this.

Photo by

 
A100:

In its simplest form:

You just need to change your approach to the calculations themselves (do intermediate return as often as required by the task). But if it is complicated, consider at the 1st stage that OnMain is absent for you (you move the main code not to OnMain, but to OnTrade2XX), respectively you don't need to learn anything in OnMain

What is OnMain? How can there be more than one event in the queue in OnMain if every event calls OnMain to handle the queue?

 
fxsaber:

Need to run on an account with a lot of trading history.

Not the point anymore - something in the Kingdom of Denmark .... what's the rest of the text? ))

 

Test1
 
fxsaber:

Please ask readers to quote their results of this script.

Run from my not-so-new laptop.


 

Started 3 times on different characters. These are the results:

2020.05.29 14:21:52.586 t2 (EURUSD,H1)  HistoryDealsTotal() = 4987
2020.05.29 14:21:52.588 t2 (EURUSD,H1)  HistoryOrdersTotal() = 4981
2020.05.29 14:21:52.757 t2 (EURUSD,H1)  100000 HistorySelect = 169.73 ms


2020.05.29 14:23:08.299 t2 (USDCHF,H4)  HistoryDealsTotal() = 4987
2020.05.29 14:23:08.299 t2 (USDCHF,H4)  HistoryOrdersTotal() = 4981
2020.05.29 14:23:08.480 t2 (USDCHF,H4)  100000 HistorySelect = 181.60 ms


2020.05.29 14:23:37.074 t2 (USDCAD,H1)  HistoryDealsTotal() = 4987
2020.05.29 14:23:37.074 t2 (USDCAD,H1)  HistoryOrdersTotal() = 4981
2020.05.29 14:23:37.238 t2 (USDCAD,H1)  100000 HistorySelect = 163.83 ms

Resource:

2020.05.29 14:25:26.874 Terminal        MetaTrader 5 x64 build 2460 started for MetaQuotes Software Corp.
2020.05.29 14:25:26.876 Terminal        Windows 10 build 17763, AMD Phenom II X3 720 Processor, 10 / 15 Gb memory, 597 / 930 Gb disk, IE 11, UAC, Admin, GMT+3


The result, imho, is excellent.

And there are many different processes running on computer, average CPU activity ~=50-65%.

 
fxsaber:


Please ask readers to cite their results of this script.

2020.05.29 14:58:20.187 ddd (Si-6.20,M1)        HistoryDealsTotal() = 4267
2020.05.29 14:58:20.187 ddd (Si-6.20,M1)        HistoryOrdersTotal() = 43089
2020.05.29 14:58:24.777 ddd (Si-6.20,M1)        100000 HistorySelect = 4589.30 ms
 
Anton:

Even a frightening 20000ms / 100000 cycles is far from 5-30ms per call.

#include <fxsaber\Benchmark.mqh> // https://c.mql5.com/3/321/Benchmark.mqh

void OnStart()
{
  MqlTick Tick;

  if (SymbolInfoTick(_Symbol, Tick))
    for (int i = 0; i < 100000; i++)
      _B(HistorySelect(Tick.time, INT_MAX), 5);
}
        Alert: Time[Test6.mq5 9: HistorySelect(Tick.time,INT_MAX)] = 32 ms.
        Alert: Time[Test6.mq5 9: HistorySelect(Tick.time,INT_MAX)] = 6 ms.


In combat EAs, I've wrapped functions everywhere in suspicious places into _B(FuncName(...), AlertTime). Here is a short excerpt of the log from the most recent entries.

2020.05.29 15:08:41.806 Alert: Time[NewTicks.mqh 271: NEWTICKS::IsHistoryDeals(MarketWatchTick.time_msc)] = 20 ms.
2020.05.29 15:08:41.806 Alert: Time[SyncChannel.mqh 381: NEWTICKS::CheckFreshTicks(::LastTicks)] = 21 ms.
2020.05.29 15:08:42.793 Alert: Time[NewTicks.mqh 112: ::HistorySelect(TimeMsc/1000,INT_MAX)] = 8 ms.
2020.05.29 15:08:42.793 Alert: Time[NewTicks.mqh 271: NEWTICKS::IsHistoryDeals(MarketWatchTick.time_msc)] = 8 ms.
2020.05.29 15:08:42.925 Alert: Time[NewTicks.mqh 112: ::HistorySelect(TimeMsc/1000,INT_MAX)] = 6 ms.
2020.05.29 15:08:42.930 Alert: Time[NewTicks.mqh 247: NEWTICKS::IsHistoryDeals(Ticks[Size-1].time_msc)] = 7 ms.
2020.05.29 15:08:42.930 Alert: Time[SyncChannel.mqh 381: NEWTICKS::CheckFreshTicks(::LastTicks)] = 11 ms.
2020.05.29 15:08:42.952 Alert: Time[NewTicks.mqh 112: ::HistorySelect(TimeMsc/1000,INT_MAX)] = 6 ms.
2020.05.29 15:08:42.952 Alert: Time[NewTicks.mqh 271: NEWTICKS::IsHistoryDeals(MarketWatchTick.time_msc)] = 6 ms.
2020.05.29 15:08:44.557 Alert: Time[NewTicks.mqh 112: ::HistorySelect(TimeMsc/1000,INT_MAX)] = 7 ms.
2020.05.29 15:08:44.557 Alert: Time[NewTicks.mqh 271: NEWTICKS::IsHistoryDeals(MarketWatchTick.time_msc)] = 12 ms.
2020.05.29 15:08:44.557 Alert: Time[SyncChannel.mqh 381: NEWTICKS::CheckFreshTicks(::LastTicks)] = 12 ms.
2020.05.29 15:08:45.010 Alert: Time[NewTicks.mqh 112: ::HistorySelect(TimeMsc/1000,INT_MAX)] = 5 ms.
2020.05.29 15:08:45.010 Alert: Time[NewTicks.mqh 247: NEWTICKS::IsHistoryDeals(Ticks[Size-1].time_msc)] = 6 ms.
2020.05.29 15:08:46.303 Alert: Time[NewTicks.mqh 112: ::HistorySelect(TimeMsc/1000,INT_MAX)] = 24 ms.
2020.05.29 15:08:46.303 Alert: Time[NewTicks.mqh 271: NEWTICKS::IsHistoryDeals(MarketWatchTick.time_msc)] = 32 ms.
2020.05.29 15:08:46.303 Alert: Time[SyncChannel.mqh 381: NEWTICKS::CheckFreshTicks(::LastTicks)] = 32 ms.
2020.05.29 15:08:51.984 Alert: Time[NewTicks.mqh 112: ::HistorySelect(TimeMsc/1000,INT_MAX)] = 15 ms.
The time column shows how often the friezes occur.
Files:
Benchmark.mqh  2 kb
 
2020.05.29 14:59:37.947    Test_HS (USDJPY,M15)    HistoryDealsTotal() = 5097
2020.05.29 14:59:37.948    Test_HS (USDJPY,M15)    HistoryOrdersTotal() = 5154
2020.05.29 14:59:37.961    Test_HS (USDJPY,M15)    100000 HistorySelect = 13.81 ms

Resource:

2020.05.29 14:49:51.173 Terminal        MetaTrader 5 x64 build 2460 started for MetaQuotes Software Corp.
2020.05.29 14:49:51.175 Terminal        Windows 10 build 19041, Intel Core i7-9700  @ 3.00 GHz, 54 / 63 Gb memory, 78 / 222 Gb disk, IE 11, UAC, GMT+3