我如何在MQL5中获得Open,Low,High,Close参数? - 页 7

 
Igor Makanu:


测量。

2019.07.30 00:44:29.156 tst_iXXX_Copy (EURUSD,H1) CopyClose: loops=1410065408 ms=69407

2019.07.30 00:45:29.408 tst_iXXX_Copy (EURUSD,H1) iClose: loops=1410065408 ms=60250

嗯,我想一些版主需要一个火焰般的问候 ))))

运行脚本。

2019.07.30 03:58:46.425 CopyClose: loops=-2147483648 ms=0
2019.07.30 03:58:46.425 iClose: loops=-2147483648 ms=0

怎么了?(没有时间去弄清楚)

 
Artyom Trishkin:

运行脚本。

怎么了?(没有时间去弄清楚)

没有对图表上的条数进行检查,也许是通过一个不存在的条数退出--我在eu上有无限期和H1期,rand()似乎最多只能给出6.5万条。


我已经弹出了rand()的编译器,这里是所有4个方法的正确测试。

// Позволяет, как в MT4, работать с таймсериями: Open[Pos], High[Pos], Low[Pos], Close[Pos], Time[Pos], Volume[Pos].
// А так же задает привычные MT4-функции: iOpen, iHigh, iLow, iClose, iTime, iVolume.
#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)
#define    test(M,S,EX)        {uint mss=GetTickCount();int nn=(int)pow(10,M);for(int tst=0;tst<nn&&!_StopFlag;tst++){EX;} \
                                printf("%s: loops=%i ms=%u",S,nn,GetTickCount()-mss);}
//+------------------------------------------------------------------+
void OnStart()
  {
   double buff[1];
   MqlRates rates[1];
   srand(GetTickCount());
   test(10,"CopyClose",CopyClose(_Symbol,_Period,rand(),1,buff));
   srand(GetTickCount());
   test(10,"iClose",iClose(NULL,0,rand())); 
   srand(GetTickCount());
   test(10,"Close[i]",Close[rand()]); 
   srand(GetTickCount());
   test(10,"CopyRates",CopyRates(_Symbol,_Period,rand(),1,rates)); 
  }
//+------------------------------------------------------------------+

2019.07.30 00:59:10.911 tst_iXXX_Copy (EURUSD,H1) CopyClose: loops=1410065408 ms=69765

2019.07.30 01:01:23.655 tst_iXXX_Copy (EURUSD,H1) iClose: loops=1410065408 ms=132735

2019.07.30 01:03:51.541 tst_iXXX_Copy (EURUSD,H1) Close[i]: loops=1410065408 ms=147890

2019.07.30 01:05:19.872 tst_iXXX_Copy (EURUSD,H1) CopyRates: loops=1410065408 ms=88328

 
Igor Makanu:

没有对图表上的条数进行检查,它可能会在不存在的条数上崩溃--我在eu上有无限期和H1期,rand()似乎最多只能给出6.5万条。


我已经弹出了rand()的编译器,这里是所有4个方法的正确测试。

2019.07.30 00:59:10.911 tst_iXXX_Copy (EURUSD,H1) CopyClose: loops=1410065408 ms=69765

2019.07.30 01:01:23.655 tst_iXXX_Copy (EURUSD,H1) iClose: loops=1410065408 ms=132735

2019.07.30 01:03:51.541 tst_iXXX_Copy (EURUSD,H1) Close[i]: loops=1410065408 ms=147890

2019.07.30 01:05:19.872 tst_iXXX_Copy (EURUSD,H1) CopyRates: loops=1410065408 ms=88328

2019.07.30 04:12:50.825 CopyClose: loops=-2147483648 ms=0
2019.07.30 04:12:50.825 iClose: loops=-2147483648 ms=0
2019.07.30 04:12:50.825 Close[i]: loops=-2147483648 ms=0
2019.07.30 04:12:50.825 CopyRates: loops=-2147483648 ms=0
当你需要一个文件时,不知何故,这不是好事 :)
 
Artyom Trishkin:
当你需要一个文件的时候,不知怎么的就不好了 :)

嗯,我想没有半升的酒是不可能的......

为什么我的源代码中的loops=-2147483648不同?

;)

PS:对ulong- ints的定义中进行替换--如果你要测试到早上))))。

 
Igor Makanu:

嗯,我想没有半升的酒是不可能的......

为什么我的源代码中的loops=-2147483648不同?

;)

PS:要在定义中ulong-into的ints - 如果你要测试到早上))))。

被替换。

2019.07.30 04:26:12.849 CopyClose: loops=1410065408 ms=71234
2019.07.30 04:26:12.849 iClose: loops=1410065408 ms=0
2019.07.30 04:26:12.849 Close[i]: loops=1410065408 ms=0
2019.07.30 04:26:12.849 CopyRates: loops=1410065408 ms=0

:))

 
Artyom Trishkin:

被替换。

:))

MQL-源代码是一对一的,我从终端日志中复制了测试结果

嗯,很难猜测调皮的笔者还挖到了什么地方 ))))

我不是那么热衷于它,代码工作得很好-- 对我很有效!我从这里得到它,当我们讨论时

SZY: Win10 - 64, build 2093 (Intel Core - 8GB RAM) - 没有发现问题,你有什么?

--------------

附上......这是一个脚本,在脚本文件夹中......不知道还有什么建议

附加的文件:
 
在Win10 x64上,所有的核心都在工作
2019.07.30 00:25:29.057 Test (GBPUSD,M1)   CopyClose: loops=1410065408 ms=72953
2019.07.30 00:27:51.501 Test (GBPUSD,M1)   iClose:    loops=1410065408 ms=143625
2019.07.30 00:30:17.904 Test (GBPUSD,M1)   Close[i]:  loops=1410065408 ms=149078
2019.07.30 00:31:56.618 Test (GBPUSD,M1)   CopyRates: loops=1410065408 ms=88891

在Debian x64的Wine下,由于某种原因,只有一个内核在运行。
2019.07.30 00:38:03.104 Test (GBPUSD,M1)   CopyClose: loops=1410065408 ms=119863
2019.07.30 00:41:10.478 Test (GBPUSD,M1)   iClose:    loops=1410065408 ms=187364
2019.07.30 00:44:16.935 Test (GBPUSD,M1)   Close[i]:  loops=1410065408 ms=186449
2019.07.30 00:46:29.732 Test (GBPUSD,M1)   CopyRates: loops=1410065408 ms=132794
附加的文件:
CPU_Win10.png  47 kb
CPU_Wine.png  21 kb
 
Igor Makanu:

MQL-源代码完全相同,我从终端日志中复制了测试结果

嗯,很难猜测调皮的笔者还挖到了哪里 ))))

我不是那么热衷于它,代码工作得很好-- 对我很有效!我从这里得到它,当我们讨论时

SZY: Win10 - 64, build 2093 (Intel Core - 8GB RAM) - 没有发现问题,你有什么?

--------------

附上......这是一个脚本,在脚本文件夹中......不知道还有什么建议

// Позволяет, как в MT4, работать с таймсериями: Open[Pos], High[Pos], Low[Pos], Close[Pos], Time[Pos], Volume[Pos].
// А так же задает привычные MT4-функции: iOpen, iHigh, iLow, iClose, iTime, iVolume.
#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)
#define    test(M,S,EX)        {ulong mss=GetTickCount();ulong nn=(ulong)pow(10,M);for(ulong tst=0;tst<nn&&!_StopFlag;tst++){EX;} \
                                printf("%s: loops=%i ms=%u",S,nn,GetTickCount()-mss);}
//+------------------------------------------------------------------+
void OnStart()
  {
   double buff[1];
   MqlRates rates[1];
   srand(GetTickCount());
   test(10,"CopyClose",CopyClose(_Symbol,_Period,rand(),1,buff));
   srand(GetTickCount());
   test(10,"iClose",iClose(NULL,0,rand())); 
   srand(GetTickCount());
   test(10,"Close[i]",Close[rand()]); 
   srand(GetTickCount());
   test(10,"CopyRates",CopyRates(_Symbol,_Period,rand(),1,rates)); 
  }
//+------------------------------------------------------------------+

Vin10 - 64 , build 2093 (Intel Core i3-3217U CPU @ 1.80GHz - 12GB RAM)- 没有发现问题...

 
Artyom Trishkin:

注意到的问题...

这里唯一要做的是减少循环次数,如果有一个地方的脚本可以工作--使用GetLastError()解包来寻找它。

或者:或者是终端的 一些设置?- 嗯,有哪些设置?- 图表上的条数,仅此而已

 
Igor Makanu:

这里唯一要做的是减少循环次数,如果有一个地方的脚本可以工作--使用GetLastError()解包来寻找它。

或者:或者是终端的 一些设置?- 嗯,有哪些设置?- 图表上的条数 - 就是这样。

我没有时间去寻找它。我以为有什么 "出格 "的东西--我只是运行它,看到了结果。所以......。是的,而且该脚本不能立即工作,一直挂着,直到你按下其图标上的PCM强行关闭它。而只有这样,那里的东西才会被印出来。一般来说--由于某种原因,使用宏的时候会有麻烦。