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

 
Renat Akhtyamov:

I'm used to the 4-pack, it's more compact and more readable

;)

my compact example is on the front page... that's basically where it all started ))))

 
Igor Makanu:

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?

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

Yes, it works:

2019.07.31 00:38:01.936 Start test № 1...
2019.07.31 00:38:31.097 CopyClose : loops=500000000 , ms=29015
2019.07.31 00:38:31.097 Start test № 2...
2019.07.31 00:41:25.095 iClose : loops=500000000 , ms=173875
2019.07.31 00:41:25.095 Start test № 3...
2019.07.31 00:44:29.777 Close[i] : loops=500000000 , ms=184547
2019.07.31 00:44:29.777 Start test № 4...
2019.07.31 00:45:01.074 CopyRates : loops=500000000 , ms=31172
2019.07.31 00:45:01.074 End script

Bottom line:

  • 29 seconds CopyClose()
  • 173 seconds iClose()
  • 184 sec Close[]
  • 31 seconds CopyRates()

What's wrong? Why do I have a difference of more than six times?

SZ run on D1

 
Artyom Trishkin:

What's wrong? Why do I have a difference of more than six times?


Igor Makanu:

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

)))

 

Igor Makanu:

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

)))

Did a test on H1, no discernible difference:

2019.07.31 00:55:30.290 Start test № 1...
2019.07.31 00:55:58.234 CopyClose : loops=500000000 , ms=27812
2019.07.31 00:55:58.234 Start test № 2...
2019.07.31 00:58:59.095 iClose : loops=500000000 , ms=180734
2019.07.31 00:58:59.095 Start test № 3...
2019.07.31 01:02:06.834 Close[i] : loops=500000000 , ms=187610
2019.07.31 01:02:06.834 Start test № 4...
2019.07.31 01:02:38.365 CopyRates : loops=500000000 , ms=31406
2019.07.31 01:02:38.365 End script

and bits and bytes have nothing to do with it?

 
Artyom Trishkin:

and bits and bytes have nothing to do with it?

I'm not going to tell you that your computer must be stupid, am I?

I've tested several times, Roman has tested - the results are comparable.

For this test, the speed of the hard drive should not be critical, there is not much left: OS, and hardware = memory + CPU, somewhere there is something slow,

there is of course an option in some "inner world" Core i3 , i have a Core™ i3-4170

 
Igor Makanu:

I'm not going to tell you that your computer must be stupid, am I?

I have tested several times, Roman has tested - the results are comparable

For this test, the speed of the hard drive should not be critical, there is not much left: OS, and hardware = memory + CPU, somewhere there is something that lags,

there is of course an option in some "inner world" Core i3 , i have a Core™ i3-4170

I have a test EA hanging on the second symbol, in which the event control in the timer is constant. We can assume that it affects it somehow. And only onnon CopyXXX functions. There is no reason to remove it from the chart at the moment - its presence is more important for my current affairs than this test.

 
Artyom Trishkin:

Did a test on H1, no noticeable difference:

The developers once said that the new iXXX functions in 5 are just a wrapper for CopyXXX functions.

Therefore, no difference in single queries is to be expected.

 
Renat Akhtyamov:
What is the verdict on function speed - which is faster?
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
int Count=5000000; // кол-во проходов
//---
void OnStart(void)
  {
   Print("Bench_1: ",Bench_1(Count)," msc");
   Print("Bench_2: ",Bench_2(Count)," msc");
  }
//+------------------------------------------------------------------+
//| Bench_1                                                                 |
//+------------------------------------------------------------------+
ulong Bench_1(const int _count)
  {
   const ulong  StartTime=GetMicrosecondCount();
//---
   for(int i=0; i<Count;i++)
     {
      datetime time  = iTime(Symbol(),Period(),0);
      double   open  = iOpen(Symbol(),Period(),0);
      double   high  = iHigh(Symbol(),Period(),0);
      double   low   = iLow(Symbol(),Period(),0);
      double   close = iClose(NULL,PERIOD_CURRENT,0);
      long     volume= iVolume(Symbol(),0,0);
     }
//---
   return(GetMicrosecondCount() - StartTime);
  }
//+------------------------------------------------------------------+
//| Bench_2                                                                 |
//+------------------------------------------------------------------+
ulong Bench_2(const int _count)
  {
   datetime  time[];
   double    open[];   // Open (цены открытия бара)
   double    high[];   // High (цены максимума бара)
   double    low[];    // Open (цены минимума бара)
   double    close[];    // Open (цены минимума бара)
   long      volume[]; // Close (цены закрытия бара)

   const ulong  StartTime=GetMicrosecondCount();
//---
   for(int i=0; i<Count;i++)
     {
      CopyTime(Symbol(),Period(),1,1,time);
      CopyOpen(Symbol(),Period(),1,1,open);
      CopyHigh(Symbol(),Period(),1,1,high);
      CopyLow(Symbol(),Period(),1,1,low);
      CopyClose(Symbol(),Period(),1,1,close);
      CopyTickVolume(Symbol(),Period(),1,1,volume);
//---
      datetime _time  = time[0];
      double   _open  = open[0];
      double   _high  = high[0];
      double   _low   = low[0];
      double   _close = close[0];
      long     _volume= volume[0];
     
}
//---
   return(GetMicrosecondCount() - StartTime);
  }
//+------------------------------------------------------------------+
the author of the script can't remember who
 
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 forgot about testing and optimization, Igor. That's where the speed is needed.

 
Andrey Khatimlianskii:

I forgot about testing and optimisation, Igor. That's where the speed is needed.

Yeah, well... There's just not a serious bunch of people here discussing this topic, so it completely slipped my mind what it's all for ))))

You're right! - But we need a convenient use of CopyOpen() functions... to do, and probably if we wrap CopyOpen() call in additional function, then performance gain will be lost.

ZZY: imho, in general it's like everywhere else - you write in assembler, you get long development time and not the fact that final performance will be higher than using C++, which you wrote in 15 minutes - you should check it