MT5 and speed in action - page 40

 
Andrey Khatimlianskii:

Why collapse the charts when you can collapse the whole terminal?

Checked. CPU load is higher than if you minimise charts, Market Watch and Tools.


I could be wrong.

 
Please add TERMINAL_IS_MINIMIZED similar to CHART_IS_MINIMIZED. So far we have to use a DLL solution.
user32::IsIconic(TerminalHandle)
To understand that you can remove the same mouse polls, don't draw panels, etc.
 

Please share the results of running this EA from your VPS (not your home machine).

#include <fxsaber\Benchmark\Benchmark.mqh> // https://www.mql5.com/ru/code/31279

const bool Init = EventSetTimer(1);

void OnTimer()
{  
  _B(GetMicrosecondCount(), 1); // Замеряем длительность выполнения GetMicrosecondCount()
}


On this VPS

2020.10.03 20:21:49.222 Terminal        MetaTrader 5 x64 build 2629 started for MetaQuotes Software Corp.
2020.10.03 20:21:49.222 Terminal        Windows Server 2012 R2 build 9600 on KVM, Intel Xeon E3-12 xx v2 (Ivy Bridge, IBRS), 4 / 5 Gb memory, 7 / 38 Gb disk, IE 11, RDP, UAC, Admin, GMT+3


result.

2020.10.04 12:01:22.763 Test6 (EOSUSD,M1)       Alert: Time[Test6.mq5 7 in OnTimer: GetMicrosecondCount()] = 26 mсs.
2020.10.04 12:01:23.747 Test6 (EOSUSD,M1)       Alert: Time[Test6.mq5 7 in OnTimer: GetMicrosecondCount()] = 33 mсs.
2020.10.04 12:01:24.747 Test6 (EOSUSD,M1)       Alert: Time[Test6.mq5 7 in OnTimer: GetMicrosecondCount()] = 36 mсs.
2020.10.04 12:01:25.748 Test6 (EOSUSD,M1)       Alert: Time[Test6.mq5 7 in OnTimer: GetMicrosecondCount()] = 32 mсs.
2020.10.04 12:01:26.762 Test6 (EOSUSD,M1)       Alert: Time[Test6.mq5 7 in OnTimer: GetMicrosecondCount()] = 23 mсs.


It is desirable to provide the VPS configuration along with the result, as shown above.


Faced with the fact that literally all functions are slow. Before changing VPS, I want to compare with other solutions and understand which one is better to choose. So please share for an objective picture.


I can use any terminal, MT4/MT5. But I am more interested in 5, of course.

 
Tried replacing it with the WinAPI version.
#import "kernel32.dll"
  int QueryPerformanceCounter(ulong &lpPerformanceCount);
  int QueryPerformanceFrequency(ulong &lpFrequency);
#import

ulong QueryPerfomanceCounter() { ulong value;  if (QueryPerformanceCounter(value)) return value;  return 0; } 

ulong QueryPerformanceFrequency() { ulong freq = 0;  if (kernel32::QueryPerformanceFrequency(freq)) return freq;  return 0; }  


// https://www.mql5.com/ru/forum/170952/page89#comment_8203859
ulong GetPerfomanceCount_mcs()
{ 
  static ulong freq= QueryPerformanceFrequency();
  return freq ? QueryPerfomanceCounter()*1000000/freq : 0;
}

#define GetMicrosecondCount GetPerfomanceCount_mcs
The result is identical to the regular one. Apparently, the internal implementation is the same. Is there some other implementation of microsecond metering?
Особенности языка mql5, тонкости и приёмы работы
Особенности языка mql5, тонкости и приёмы работы
  • 2018.07.27
  • www.mql5.com
В данной теме будут обсуждаться недокументированные приёмы работы с языком mql5, примеры решения тех, или иных задач...
 

Determines whether or not a programme is running on the braked machine.

// Возвращает true, если тормозной VPS.
bool IsFreezeVPS()
{
  static bool FirstRun = true;
  static bool Res;
  
  if (FirstRun)
  {
    if (Res = ::GetMicrosecondCount() - ::GetMicrosecondCount())
      ::Alert("Warning: FreezeVPS - https://www.mql5.com/ru/forum/342090/page40#comment_18579094");
    
    FirstRun = false;
  }
  
  return(Res);
}
 

Seems to have bypassed the GetMicrosecondsCount brakes on VPS machines. It may seem like nothing. In fact, combat EAs were killing the VPS with CPU load, because microseconds counts must be fully used in trading environment snapshots, which in turn are designed not to load, but to take the load off the CPU.


Who else got in here? Snapshots, and now GetMicrosecondsCount...

 
fxsaber:

Determines whether or not a programme is running on the braked machine.

Whether or not the difference is null is a matter of chance:

void OnStart()
{
        const int max = 2000000;
        int count = 0;
        for ( int i = 0; i < max; i++ )
                if ( GetMicrosecondCount() != GetMicrosecondCount() )
                        count++;
        Print( max, ":" ,count );
}

Result: 2000000:213579

 
A100:

Zero or not zero is a matter of chance:

Result: 2000000:213579

Yes, that's why I use such a condition in mqh.

    // Несколько проверок - от ложных срабатываний.
    bool Res = (bool)(::GetMicrosecondCount() - ::GetMicrosecondCount()) &&
               (bool)(::GetMicrosecondCount() - ::GetMicrosecondCount()) &&
               (bool)(::GetMicrosecondCount() - ::GetMicrosecondCount()) &&
               (bool)(::GetMicrosecondCount() - ::GetMicrosecondCount()) &&
               (bool)(::GetMicrosecondCount() - ::GetMicrosecondCount());
 
fxsaber:

Yes, that's why I use this condition in mqh.

It's only 5 checks. I have a slow computer (tablet), but even I only have a difference on every2000000/213579=10th check. And the fact that I have a slow one is confirmed by the fact that even this is not reproduced by anyone else:

Forum on trading, automated trading systems and trading strategy testing

MT5 and speed in action

A100, 2020.09.05 00:13

Also about delays

and all manual charting (trend, Fibonacci, etc.) is also slow

The settings are all by default:

  • Server: MetaQuotes-Demo
  • History: available since 01.01.1971
  • Precise time frame: none
  • Max bars in window: 100000
  • Chart type: candlesticks
  • Scaling down of the chart: Maximum

Symbol, period bars latency
EURUSD, Mounthly 597 go to
EURUSD, Weekly
2590 Check out
EURUSD, Daily

12797

no

Some kind of inverse dependence: the less bars, the slower

On monthly and weekly charts for example EURGBP (where there is no such deep history) - no delays


 
A100:

That's only 5 checks. I have a slow computer (tablet), but even I only have a difference on every2000000/213579=10th check. And the fact that I have a slow one is confirmed by the fact that even this is not reproduced by anyone else:

If five consecutive checks give a non-zero result, it's a slow GetMicrosecondsCount. Of course, there may be other (even more logical) options to determine if a problem exists. I've left it that way for now.

As for working with bar history - I don't use it. It is always M1+5000 bars. The task is to trade quickly.