ライブラリ: 時間に厳密なアプリケーションiTimeSeries - ページ 2

 
nicholishen:


その通りだ。このテストはアランのベンチマークを反映するように設計されている。このアルゴリズムの実世界での使用をより正確にシミュレートするために、タイムシフトを使用した例を示します。

https://i.imgtc.com/rhYzQFj.png

iBarShift benchmark 3 based on 6417330 runs.
=======================================================
iBarShift(Alain Verleyen) for 2005.03.14 12:29:59 is 4295861 in 22086.599 milliseconds.
-------------------------------------------------------------
iBarShift3 for 2005.03.14 12:29:59 is 4295861 in 10717.378 milliseconds.
-------------------------------------------------------------
iBarShift(direct function call) for 2005.03.14 12:29:59 is 4295861 in 20133.535 milliseconds.
-------------------------------------------------------------
iBar.Shift(performance mode) for 2005.03.14 12:29:59 is 4295861 in 19648.571 milliseconds.
-------------------------------------------------------------
 
 
Stanislav Korotky:
iBarShift3とは?
このスレッドのソースコードに
 
fxsaber:
デバッグモードで テストしているのですね?スクリプトをコンパイルし、チャートに適用してテストしてください。
 
nicholishen:
デバッグモードでテストしているのですね?スクリプトをコンパイルし、チャートに適用してテストしてください。
リリース 1606
iBarShift benchmark 3 based on 100000 runs.
=======================================================
iBarShift(Alain Verleyen) for 2017.03.30 12:36:53 is 71117 in 349.886 milliseconds.
-------------------------------------------------------------
iBarShift3 for 2017.03.30 12:36:53 is 71117 in 168.600 milliseconds.
-------------------------------------------------------------
iBarShift(direct function call) for 2017.03.30 12:36:53 is 71117 in 315.877 milliseconds.
-------------------------------------------------------------
iBar.Shift(performance mode) for 2017.03.30 12:36:53 is 71117 in 284.332 milliseconds.
 

バグ

#define  DEFINE_TIMESERIE(NAME,FUNC,T)                                                                         \
  class CLASS##NAME                                                                                           \
  {                                                                                                           \
  public:                                                                                                     \
    static T Get(const string Symb,const int TimeFrame,const int iShift)                                      \
    {                                                                                                         \
      T tValue[];                                                                                             \
                                                                                                              \
      return((Copy##FUNC((Symb == NULL) ? _Symbol : Symb, _Period, iShift, 1, tValue) > 0) ? tValue[0] : -1); \
    }                                                                                                         \
                                                                                                              \
    T operator[](const int iPos) const                                                                        \
    {                                                                                                         \
      return(CLASS##NAME::Get(_Symbol, _Period, iPos));                                                       \
    }                                                                                                         \
  };                                                                                                          \
                                                                                                              \
  CLASS##NAME  NAME;                                                                                           \
                                                                                                              \
  T i##NAME(const string Symb,const int TimeFrame,const int iShift)                                           \
  {                                                                                                           \
    return(CLASS##NAME::Get(Symb,  TimeFrame, iShift));                                                        \
  }

DEFINE_TIMESERIE(Volume,TickVolume,long)
DEFINE_TIMESERIE(Time,Time,datetime)
DEFINE_TIMESERIE(Open,Open,double)
DEFINE_TIMESERIE(High,High,double)
DEFINE_TIMESERIE(Low,Low,double)
DEFINE_TIMESERIE(Close,Close,double)

#include <iTimeSeries_nicholishen_v2.mqh>

#define  TOSTRING(A) (#A + " = " + (string)(A) + "\n")

void OnStart()
{
  CiTimeSeries iBar;
  
  if (iBar.Init())
  {
    const double PrevClose = iBar.Close(0);
    
    Print(TOSTRING(iBar.Close(0)) + TOSTRING(Close[0]));        
    
    while (!IsStopped() && (SymbolInfoDouble(_Symbol, SYMBOL_BID) == PrevClose))
      Sleep(100);
      
// iBar.Refresh();
    Print(TOSTRING(iBar.Close(0)) + TOSTRING(Close[0]));        
  }
}


結果

iBar.Close(0) = 1.17587
Close[0] = 1.17587

iBar.Close(0) = 1.17587
Close[0] = 1.17589
 
スクリプトがコンパイルされない
 
m_periodSecAdjがうまく取り込まれず、ゼロ除算 エラーになることがあります
このライブラリを適用する前に、よく対処してください。