エラー、バグ、質問 - ページ 2613

 
Vladimir Pastushak:

GetMicrosecondCount()に関する質問

そして動画の最後、プリントログには

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 この値と前回の値の差は9秒ですが、GetMicrosecondCount() では67867msecと表示されています。

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

 
Vladimir Pastushak:

また、動画の最後にプリントログを見ると

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 この値と前回の値の差は9秒ですが、GetMicrosecondCount()では67867msecと表示されています。

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

オーバーフロー...カウンタはモジュロで比較する必要があります。

 
Vladimir Pastushak:

また、動画の最後にプリントログを見ると

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

GJ 0 22:58:46.669 テスト(EURUSD,M15) 65134

GQ 0 22:58:55.914 Test (EURUSD,M15) 67867 この値と前回の値の差は9秒ですが、GetMicrosecondCount()では67867msecと表示されています。

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

残念ながら、フルコードが表示されていませんね。

100万分の1秒の計測について、映像だけを提示して、コードを完全に無視して、どう議論するつもりなのか。


もし、マイクロ秒タイマーの 測定精度を絶対に議論したいのであれば、例を実行してみてください。

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.:

残念ながら、あなたのフルコードが表示されていません。

ビデオだけを提示して、コードを完全に無視して、どうやって100万分の1秒の計測を議論するつもりなのですか?


もし、マイクロ秒タイマーの測定精度を絶対に議論したいのであれば、この例を実行してください。

測定誤差はありません。

GetMicrosecondCount()はシステムのQueryPerformanceCounterで実行され、アプリケーションの開始時間への参照は便宜上敷かれている。

自分の時間測定コードに誤りがないか探す。

標準ライブラリーを 使用しました。コードはもう少し後に掲載しますが、特に目新しいものはありません。

 

通貨と国を選べるようにしておくのは悪くないと思います。

 
ビジュアルテストモードで 最後の更新遅れテスターの後、30〜60秒ハングアップするために、歴史の冒頭でチャートをスローします。 オブジェクトの作成にバグがあり、例えばボタンを作成し、フォアグラウンドに位置し、バックグラウンドにラインの位置を作成しますが、オブジェクトが交差する場合、ボタンを押そうとすると、フォアグラウンドラインは、最初の場所で視覚的にボタンがありますが。ボタンにマウスを合わせると、作成したラインの名前を表示したメニューがポップアップします(ボタンに対して背景が表示されます)。
 

前方最適 化の結果を完成前に確認できるようにしたい。

これらの結果は、メインの最適化の結果と同じように、ウィンドウ内に即座に表示されるようにしてほしいです。そして現在、そのようなウィンドウはまったくありません。

同じ(本質的に)プロセスで、なぜあるウィンドウがあり、別のウィンドウがないのか、不思議です......。

 

私が理解する限り、Market Overviewウィンドウでは、シンボルにビッド価格とアスク価格が表示されるようになりましたが、これはスイッチオフになっていないのでしょうか?

ビルド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からの同じコードは問題なく動作します