Come posso ottenere i parametri Open,Low,High,Close in MQL5? - pagina 7

 
Igor Makanu:


misurato:

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

hmm, penso che qualche moderatore abbia bisogno di un saluto fiammeggiante ))))

Esecuzione dello script:

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

Cosa c'è che non va? (non c'è tempo per capirlo)

 
Artyom Trishkin:

Esecuzione dello script:

Cosa c'è che non va? (non c'è tempo per capirlo)

non c'è nessun controllo per il numero di barre sul grafico, forse l'uscita da una barra inesistente - ho periodo illimitato e H1 su eu, rand() sembra dare 65 mila al massimo


Ho fatto saltare il compilatore rand(), ecco un test corretto di tutti e 4 i metodi:

// Позволяет, как в 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:

non c'è nessun controllo per il numero di barre sul grafico, potrebbe bloccarsi su una barra inesistente - ho un periodo illimitato e H1 su eu, rand() sembra dare 65 mila al massimo


Ho fatto saltare il compilatore rand(), ecco un test corretto di tutti e 4 i metodi:

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
In qualche modo non va bene quando hai bisogno di un file :)
 
Artyom Trishkin:
In qualche modo non va bene quando hai bisogno di un file :)

Hmm, immagino che non sia possibile senza un mezzo litro...

perché loops=-2147483648 nel mio codice sorgente è diverso!

;)

PS: a ulong- ints sostituire nel define - se avete intenzione di testare fino al mattino ))))

 
Igor Makanu:

Hmm, immagino che non sia possibile senza un mezzo litro...

perché loops=-2147483648 nel mio codice sorgente è diverso!

;)

PS: per ulonare gli ints nella definizione - se avete intenzione di testare fino al mattino ))))

Sostituito:

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:

Sostituito:

:))

Il codice MQL-source è uno a uno, ho copiato il test dal log del terminale

hmm, difficile indovinare dove altro hanno scavato le mani birichine ))))

Non sono così entusiasta, il codice funziona bene - ha funzionato per me! L'ho preso da qui quando abbiamo discusso

SZY: Win10 - 64, build 2093 (Intel Core - 8GB RAM) - nessun problema notato, cosa hai lì?

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

allegato...è uno script, nella cartella script...non so cos'altro suggerire

File:
 
Su Win10 x64 tutti i core sono impegnati
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

Sotto Wine su Debian x64 solo un kernel gira per qualche motivo
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
File:
CPU_Win10.png  47 kb
CPU_Wine.png  21 kb
 
Igor Makanu:

Il codice MQL-source è esattamente lo stesso, ho copiato il test dal log del terminale

hmm, è difficile indovinare dove altro hanno scavato le penne birichine ))))

Non sono così entusiasta, il codice funziona bene - ha funzionato per me! L'ho preso da qui quando abbiamo discusso

SZY: Win10 - 64, build 2093 (Intel Core - 8GB RAM) - nessun problema notato, cosa hai lì?

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

allegato...è uno script, nella cartella script...non so cos'altro suggerire

// Позволяет, как в 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)- nessun problema notato...

 
Artyom Trishkin:

problemi notati...

L'unica cosa da fare qui è ridurre il numero di cicli e se c'è un posto dove lo script funzionerà - usare lo spacchettamento GetLastError() per cercarlo

in alternativa: o alcune impostazioni del terminale? - hmm, che impostazioni ci sono? - numero di barre sul grafico e questo è tutto

 
Igor Makanu:

L'unica cosa da fare qui è ridurre il numero di cicli e se c'è un posto dove lo script funzionerà - usare l'annullamento GetLastError() per cercarlo

in alternativa: o alcune impostazioni del terminale? - hmm, che impostazioni ci sono? - Numero di barre sul grafico - è tutto.

Non ho tempo per cercarlo. Ho pensato che ci fosse qualcosa "fuori dalla scatola" - l'ho appena eseguito e ho visto il risultato. E così... Sì, e lo script non funziona immediatamente, e si blocca finché non lo si chiude forzatamente premendo il PCM sulla sua icona. E solo allora si stampa qualcosa. In generale - con le macro una seccatura per qualche motivo.

Motivazione: