Errors, bugs, questions - page 2613

 
Vladimir Pastushak:

Question on GetMicrosecondCount()

And at the end of the video, the print log shows

OD 0 22:58:46.604 Test (EURUSD,M15) 66190

GJ 0 22:58:46.669 Test (EURUSD,M15) 65134

GQ 0 22:58:55.914 Test (EURUSD,M15) 67867 The difference between this value and the previous one is 9 seconds, but GetMicrosecondCount() shows 67867 msec

PD 0 22:58:56.715 Test (EURUSD,M15) 66139

 
Vladimir Pastushak:

And also at the end of the video the print log shows

OD 0 22:58:46.604 Test (EURUSD,M15) 66190

GJ 0 22:58:46.669 Test (EURUSD,M15) 65134

GQ 0 22:58:55.914 Test (EURUSD,M15) 67867 The difference between this value and the previous one is 9 seconds, but GetMicrosecondCount() shows 67867 msec

PD 0 22:58:56.715 Test (EURUSD,M15) 66139

overflow..counters must be compared modulo

 
Vladimir Pastushak:

And also at the end of the video the print log shows

OD 0 22:58:46.604 Test (EURUSD,M15) 66190

GJ 0 22:58:46.669 Test (EURUSD,M15) 65134

GQ 0 22:58:55.914 Test (EURUSD,M15) 67867 The difference between this value and the previous one is 9 seconds, but GetMicrosecondCount() shows 67867 msec

PD 0 22:58:56.715 Test (EURUSD,M15) 66139

Unfortunately you didn't show your full code.

How are you going to discuss the measurement of millionths of a second, presenting only video and completely ignoring the code?


If you definitely want to discuss the accuracy of a microsecond timer measurement, then run the example:

void OnStart()
  {
   ulong ticks;
//---
   ticks=GetMicrosecondCount();   
   Sleep(40);
   Print("40 ms = ",GetMicrosecondCount()-ticks," msc");
//---   
   ticks=GetMicrosecondCount();   
   Sleep(10);
   Print("10 ms = ",GetMicrosecondCount()-ticks," msc");
  }

40 ms = 40354 msc
10 ms = 10487 msc

There is no measurement error.

GetMicrosecondCount() runs on the system's QueryPerformanceCounter, and the reference to the application's start time is embedded for convenience.

Look for an error in your timing code.

 
MetaQuotes Software Corp.:

Unfortunately, you haven't shown your full code.

How are you going to discuss measuring millionths of a second by presenting only a video and completely ignoring the code?


If you definitely want to discuss the accuracy of the microsecond timer measurement, then run the example:

There is no measurement error.

GetMicrosecondCount() runs on the system's QueryPerformanceCounter, and the reference to the application start time is laid in for convenience.

Look for error in your own time measurement code.

I used standard library. I'll post the code a bit later, but there is nothing new there.

 

It would not be a bad idea to keep the choice of currency and country:

 
After the last update lag tester in visual testing mode, for 30-60 seconds hangs, throws the chart at the beginning of history. There is a bug with the creation of objects, for example create a button, position in the foreground, create a line position in the background, but if the objects intersect, when you try to press the button, the foreground line, although visually the button in the first place. If you hold the mouse on the button, a menu pops up with the name of the line created (it is in the background in relation to the button).
 

I would like to be able to see the results of forward optimization before it is completed.

I would like these results to be displayed in the same way as the results of the main optimization - immediately in the window. And now there is no such window at all!

It is strange - why there is one window and not another - in the same (essentially) process...

 

As far as I understand, in the Market Overview window, the symbols now have bid and ask prices that are not switched off?

Bild 2265.

 
//+------------------------------------------------------------------+
//|                                                         Test.mq5 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_plots   1
#property indicator_buffers 1
#include <Trident\TCoreMain.mqh>
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   ::EventSetMillisecondTimer(500);
   return(INIT_SUCCEEDED);
  }
  
  void OnDeinit(const int reason) {
   ::EventKillTimer();
}

void OnTimer() {
   ::EventKillTimer();
   TestPhoto();
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

void TestPhoto() {
   string name;
   MqlDateTime  dtLocal;
   TimeToStruct(TimeLocal(), dtLocal);
   string date = IntegerToString(dtLocal.year) + IntegerToString(dtLocal.mon, 2, '0') + IntegerToString(dtLocal.day, 2, '0');
   string time = IntegerToString(dtLocal.hour, 2, '0') + "." + IntegerToString(dtLocal.min, 2, '0') + "." + IntegerToString(dtLocal.sec, 2, '0');
   name = "ScreenShots/" + date + "/" + _Symbol + "_" +date + "_" + time + ".png";
   
   if (!ChartScreenShot(0, name, 1920,1200, ALIGN_RIGHT))
      return;

   ResetLastError();
   
   for (int i=0; i < 100000; i++){
      if (FileIsExist(name,false) && FileSize(name) > 0)
         break;
   }
   //---
   int flags=FILE_READ|FILE_BIN|FILE_SHARE_READ;

   //---
   int file=FileOpen(name,flags);
   if(file<0) {
      Print("Операция FileOpen неудачна, ошибка ",GetLastError());
      return;
}
   uchar photo[];
   FileReadArray(file,photo);
   FileClose(file);
   
   Print(ArraySize(photo));
}

Reading a binary file from an indicator doesn't work!!! Similar code from EA works without problems

 
//+------------------------------------------------------------------+
//|                                                         Test.mq5 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_plots   1
#property indicator_buffers 1
#include <Trident\TCoreMain.mqh>
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   ::EventSetMillisecondTimer(500);
   return(INIT_SUCCEEDED);
  }
  
  void OnDeinit(const int reason) {
   ::EventKillTimer();
}

void OnTimer() {
   ::EventKillTimer();
   TestPhoto();
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

void TestPhoto() {
   string name;
   MqlDateTime  dtLocal;
   TimeToStruct(TimeLocal(), dtLocal);
   string date = IntegerToString(dtLocal.year) + IntegerToString(dtLocal.mon, 2, '0') + IntegerToString(dtLocal.day, 2, '0');
   string time = IntegerToString(dtLocal.hour, 2, '0') + "." + IntegerToString(dtLocal.min, 2, '0') + "." + IntegerToString(dtLocal.sec, 2, '0');
   name = "ScreenShots/" + date + "/" + _Symbol + "_" +date + "_" + time + ".png";
   
   if (!ChartScreenShot(0, name, 1920,1200, ALIGN_RIGHT))
      return;

   ResetLastError();
   
   for (int i=0; i < 100000; i++){
      if (FileIsExist(name,false) && FileSize(name) > 0)
         break;
   }
   //---
   int flags=FILE_READ|FILE_BIN|FILE_SHARE_READ;

   //---
   int file=FileOpen(name,flags);
   if(file<0) {
      Print("Операция FileOpen неудачна, ошибка ",GetLastError());
      return;
}
   uchar photo[];
   FileReadArray(file,photo);
   FileClose(file);
   
   Print(ArraySize(photo));
}
Reading the binary file from the indicator doesn't work, the same code from the EA works without problems!
Reason: