错误、漏洞、问题 - 页 2613

 
Vladimir Pastushak:

关于GetMicrosecondCount()的问题

而在视频的最后,打印记录显示

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

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

GQ 0 22:58:55.914 测试(EURUSD,M15) 67867 这个值和之前的值相差9秒,但是GetMicrosecondCount()显示67867毫秒。

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

 
Vladimir Pastushak:

另外,在视频的最后,打印记录显示

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

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

GQ 0 22:58:55.914 测试(EURUSD,M15) 67867 这个值和之前的值相差9秒,但是GetMicrosecondCount()显示67867毫秒。

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

溢出......计数器必须以模数进行比较

 
Vladimir Pastushak:

另外,在视频的最后,打印记录显示

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

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

GQ 0 22:58:55.914 测试(EURUSD,M15) 67867 这个值和之前的值相差9秒,但是GetMicrosecondCount()显示67867毫秒。

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

不幸的是,你没有显示你的完整代码。

你打算如何讨论百万分之一秒的测量,只呈现视频而完全忽视代码?


如果你肯定想讨论微秒计时器 测量的准确性,那么就运行这个例子。

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

没有测量误差。

GetMicrosecondCount()在系统的QueryPerformanceCounter上运行,为方便起见,嵌入了对应用程序启动时间的引用。

寻找你的定时代码中的错误。

 
MetaQuotes Software Corp.:

不幸的是,你没有显示你的完整代码。

你打算如何讨论测量百万分之一秒的问题,只提出一个视频,而完全忽略了代码?


如果你肯定想讨论微秒计时器测量的准确性,那么请运行这个例子。

没有测量误差。

GetMicrosecondCount()在系统的QueryPerformanceCounter上运行,为了方便起见,对应用程序开始时间的引用被放在里面。

在你自己的时间测量代码中寻找错误。

我使用了标准库。我稍后会公布代码,但那里没有什么新东西。

 

保持对货币和国家的选择也不是一个坏主意。

 
在最后一次更新后,滞后测试器在视觉测试 模式下,30-60秒内挂起,在历史开始时抛出图表。 在创建对象时有一个错误,例如,创建一个按钮,位置在前台,创建一条线,位置在后台,但如果对象相交,当你试图按下按钮时,前台的线,虽然在视觉上首先是按钮。如果你在按钮上按住鼠标,就会弹出一个菜单,上面有创建的线的名称(它在与按钮有关的背景中)。
 

我希望能在优化完成之前看到正向优化 的结果。

我希望这些结果的显示方式与主优化的结果相同--立即显示在窗口中。而现在,根本就没有这样的窗口。

奇怪的是,为什么在同一个(本质上)过程中,有一个窗口而没有另一个窗口......

 

据我所知,在 "市场概览 "窗口中,符号现在有买入和卖出价格,没有被关闭?

图片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));
}

从指标中读取二进制文件不起作用!!!来自EA的类似代码工作起来没有问题

 
//+------------------------------------------------------------------+
//|                                                         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));
}
从指标中读取二进制文件不起作用,从EA中读取同样的代码却能顺利工作!