How do I get Open,Low,High,Close parameters in MQL5? - page 8

 
Artyom Trishkin:

I won't look exactly - I don't have the time. I thought there was something "out of the box" - run it and see the result. But now ... Yes, and the script does not work immediately, and hangs until you close forcibly PKM on its icon. And only then something there is printed. In general - with macros one hassle for some reason.

And my post has the meaning of the theme bugs move?

 
Artyom Trishkin:

I won't look exactly - I don't have the time. I thought there was something "out of the box" - run it and see the result. But now ... Yes, and the script does not work immediately, and hangs until you close forcibly PKM on its icon. And only then something there is printed. All in all, macros are a pain in the ass.

Ah, there's the dog!

Have you seen my tests? There's Roman too

there are 436 seconds worth of tests = 7 minutes!

;)

ZS: I told you naughty hands stumbled on it!...the script doesn't work "out of the box"... ))))


Roman:

Does it make sense to put my post in the bug thread?

what bugs? - write in Wine and Debian that they can't fully load the CPU cores, what OS do you have MT for?

 
Igor Makanu:

Ahh, there's the doggy!

Did you see my tests? There's Roman's, too.

there are 436 seconds worth of tests = 7 minutes!

;)

ZS: I'm telling you naughty hands stumbled on it!...script doesn't work "out of the box"... ))))

Creepy :)

We should rest more...

 
Igor Makanu:

Ahh, there's the doggy!

Did you see my tests? There's Roman's, too.

there are 436 seconds worth of tests = 7 minutes!

;)

ZS: I told you naughty hands stumbled upon it!...the script doesn't work "out of the box"... ))))


what bugs? - well, write in Wine and Debian that they can't fully load the CPU cores, you have MT for which OS?

MT of course under Windows, but how can I say...
In VS Code on Debian, when I test the load of other code, all cores are loaded, so it's unnecessary to blame Debian.
Wine may be, or rather, MT is not optimized for it. Therefore, it is incomplete under Wine.
There are many linux users under Wine.

 
Igor Makanu:

Ahh, there's the doggy!

Did you see my tests? There's Roman's, too.

there are 436 seconds worth of tests = 7 minutes!

;)

ZS: I tell you naughty hands stabbed it!...the script doesn't work "out of the box"... ))))


Good. Without naughty hands, the first test was over in five minutes. The rest didn't finish in twenty. The cooler started to take off, the coffee next to it started to boil... Anyway, knocked the hell out...
 
What is the verdict on function speed - which is faster?
 
Renat Akhtyamov:
What is the verdict on the speed of the functions - which is faster?

Looks like CopyXXX() but not CopyRates(). When more than one data is required at the same time - CopyRates()

 
Artyom Trishkin:
Good. The first test has passed in five minutes without naughty hands. The rest ones were not finished even in twenty. The cooler started to take off, the coffee next to it boiled... Anyway, knocked the hell out...

hmmm, I think you have bits that don't want to build into bytes...there are basically no more options! ))))

if this thread is under the gaze of a moderator, something needs to be done... I took the macro apart for parts,

Artem, does it even work?

#property script_show_inputs

input ulong LoopCount=500000000;

// Позволяет, как в 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)
//+------------------------------------------------------------------+
void OnStart()
  {
   double c,buff[1];
   MqlRates rates[1];
   ulong i;
//-----   
   Print("Start test № 1...");
   Sleep(125);
   srand(GetTickCount());
   uint start=GetTickCount();
   for(i=0;i<LoopCount && !_StopFlag;i++)
      CopyClose(_Symbol,_Period,rand(),1,buff);
   printf("CopyClose : loops=%u , ms=%u",i,GetTickCount()-start);
//-----   
   Print("Start test № 2...");
   Sleep(125);
   srand(GetTickCount());
   start=GetTickCount();
   for(i=0;i<LoopCount && !_StopFlag;i++)
      c = iClose(NULL,0,rand());
   printf("iClose : loops=%u , ms=%u",i,GetTickCount()-start);
//-----   
   Print("Start test № 3...");
   Sleep(125);
   srand(GetTickCount());
   start=GetTickCount();
   for(i=0;i<LoopCount && !_StopFlag;i++)
      c = Close[rand()];
   printf("Close[i] : loops=%u , ms=%u",i,GetTickCount()-start);
//-----   
   Print("Start test № 4...");
   Sleep(125);
   srand(GetTickCount());
   start=GetTickCount();
   for(i=0;i<LoopCount && !_StopFlag;i++)
      CopyRates(_Symbol,_Period,rand(),1,rates);
   printf("CopyRates : loops=%u , ms=%u",i,GetTickCount()-start);
   Print("End script");
  }
//+------------------------------------------------------------------+

2019.07.30 19:42:16.639 tst_iXXX_Copy (EURUSD,H1) Start test #1...

2019.07.30 19:42:40.199 tst_iXXX_Copy (EURUSD,H1) CopyClose : loops=500000000 , ms=23422

2019.07.30 19:42:40.199 tst_iXXX_Copy (EURUSD,H1) Start test #2...

2019.07.30 19:43:26.953 tst_iXXX_Copy (EURUSD,H1) iClose: loops=500000000 , ms=46609

2019.07.30 19:43:26.953 tst_iXXX_Copy (EURUSD,H1) Start test #3...

2019.07.30 19:44:12.274 tst_iXXX_Copy (EURUSD,H1) Close[i] : loops=500000000 , ms=45156

2019.07.30 19:44:12.274 tst_iXXX_Copy (EURUSD,H1) Start test #4...

2019.07.30 19:44:42.080 tst_iXXX_Copy (EURUSD,H1) CopyRates : loops=500000000 , ms=29656

2019.07.30 19:44:42.080 tst_iXXX_Copy (EURUSD,H1) End script

Files:
 
Renat Akhtyamov:
What is the verdict on the speed of the functions - which one is faster?

they work the same, imho experiments are for experiments... here's the last test call for half a billion times, well yeah you can see the difference, the only thing left is to figure out how many ticks in a minute (~60), how many in a tick in an hour (~3600) and how many in a day (~86400) and how much these 23 seconds will run for half a billion calls ...

5 787 days = 23 seconds profit? if we use the fastest function on each tick! )))))

imho, use what's convenient and don't listen to anyone

 
Igor Makanu:

they work the same, imho experiments are for experiments... here's the last test call for half a billion times, well yeah you can see the difference, the only thing left is to figure out how many ticks in a minute (~60), how many in a tick in an hour (~3600) and how many in a day (~86400) and how much these 23 seconds will run for half a billion calls ...

5 787 days = 23 seconds profit? if we use the fastest function on each tick! )))))

imho, use what's convenient and don't listen to anyone

i got used to 4pc, more compact and more readable

I can't complain about speed and features, it's ok.

;)