程序库: 用于时间敏感应用程序的高性能 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.
-------------------------------------------------------------
 
什么是iBarShift3
 
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可能无法很好地输入,并导致除数为零的 错误
在应用该函数库之前,请妥善处理它。