Errors, bugs, questions - page 2221

 

Synthetic tool. I import minute bars, each minute bar differs by 1 point (5 digits).

I close the window with symbols, then I reopen this window, ask for minute bars from the previous load, I get

The symbols are the same for every full day. What is the error?

 
elibrarius:

Looking through the code of the Alglib package. It's full of these constructions, making the code more difficult to read:

Isn't it simpler like this?

It seems to me that the execution speed would be even higher.

Why did they make the code so complicated? Or they just ported it from another language without any modifications? But I still wonder why such a complication in the original?

This is most likely done in the original code precisely to speed things up.

Whether it will be faster in MQL must be measured, "it seems" will not work here.

 
Koldun Zloy:

This ismost likely done in the original for acceleration.

Whether it will be faster in MQL must be measured, "it seems" will not work here.

"Most likely" does not work either.
How can such a form work faster? What are you talking about!

Two extra loops and an extra array instead of one variable.

 

Nikolai Semko:

Two extra loops and an extra array instead of one variable.

Such primitive reasoning is not suitable for modern processors.

 
Koldun Zloy:

Such primitive reasoning is not suitable for modern processors.

You know better. You have more experience...

 


Koldun Zloy
:

Such primitive reasoning is not suitable for modern processors.

In essence, I'm sorry, but you are delusional.

No processor in existence today will ever

for(i=0;i<=npoints-1;i++)

faster compared to...

for(i=0;i<npoints;i++)

and accessing an array will never be faster than accessing a simple variable,

three identical loops will never be faster than one combined loop.


I have not been lazy and tested the speed of two different variants directly in the original ALGLIB so as not to be unsubstantiated :

      e=0;
      double tmp1;
      ulong t=GetMicrosecondCount();
      for(i=0;i<npoints;i++)
        {
         v=0.0;
         for(i_=0;i_<nvars;i_++)
           {
            tmp1=xy[i][i_]-ct[xyc[i]][i_];
            v+=tmp1*tmp1;
           }
         e=e+v;
        }
      t=GetMicrosecondCount()-t;
      Print("fast = "+(string)t+" микросекунд, e = "+DoubleToString(e) + " , npoints = " + (string)npoints+" , nvars = " + (string)nvars );



      e=0;
      t=GetMicrosecondCount();
      for(i=0;i<=npoints-1;i++)
        {
         for(i_=0;i_<=nvars-1;i_++)
            tmp[i_]=xy[i][i_];
         for(i_=0;i_<=nvars-1;i_++)
            tmp[i_]=tmp[i_]-ct[xyc[i]][i_];
         //--- calculation
         v=0.0;
         for(i_=0;i_<=nvars-1;i_++)
            v+=tmp[i_]*tmp[i_];
         e=e+v;
        }
      t=GetMicrosecondCount()-t;
      Print("slow = "+(string)t+" микросекунд, e = "+DoubleToString(e) + " , npoints = " + (string)npoints+" , nvars = " + (string)nvars );

result:

2018.06.27 04:36:50.265 TestClasses (GBPUSD,M6) fast = 571 микросекунд, e = 534.47773777 , npoints = 1500 , nvars = 40
2018.06.27 04:36:50.266 TestClasses (GBPUSD,M6) slow = 841 микросекунд, e = 534.47773777 , npoints = 1500 , nvars = 40
2018.06.27 04:36:50.630 TestClasses (GBPUSD,M6) fast = 577 микросекунд, e = 531.85904819 , npoints = 1500 , nvars = 40
2018.06.27 04:36:50.631 TestClasses (GBPUSD,M6) slow = 812 микросекунд, e = 531.85904819 , npoints = 1500 , nvars = 40
2018.06.27 04:36:51.143 TestClasses (GBPUSD,M6) fast = 599 микросекунд, e = 537.42685690 , npoints = 1500 , nvars = 40
2018.06.27 04:36:51.144 TestClasses (GBPUSD,M6) slow = 853 микросекунд, e = 537.42685690 , npoints = 1500 , nvars = 40
2018.06.27 04:36:51.955 TestClasses (GBPUSD,M6) fast = 600 микросекунд, e = 531.17444713 , npoints = 1500 , nvars = 40
2018.06.27 04:36:51.956 TestClasses (GBPUSD,M6) slow = 809 микросекунд, e = 531.17444713 , npoints = 1500 , nvars = 40
2018.06.27 04:36:52.344 TestClasses (GBPUSD,M6) fast = 567 микросекунд, e = 540.39509565 , npoints = 1500 , nvars = 40
2018.06.27 04:36:52.344 TestClasses (GBPUSD,M6) slow = 813 микросекунд, e = 540.39509565 , npoints = 1500 , nvars = 40
2018.06.27 04:36:52.857 TestClasses (GBPUSD,M6) fast = 690 микросекунд, e = 550.68494369 , npoints = 1500 , nvars = 40
2018.06.27 04:36:52.858 TestClasses (GBPUSD,M6) slow = 820 микросекунд, e = 550.68494369 , npoints = 1500 , nvars = 40
2018.06.27 04:36:53.229 TestClasses (GBPUSD,M6) fast = 585 микросекунд, e = 547.94313745 , npoints = 1500 , nvars = 40
2018.06.27 04:36:53.230 TestClasses (GBPUSD,M6) slow = 811 микросекунд, e = 547.94313745 , npoints = 1500 , nvars = 40
2018.06.27 04:36:53.736 TestClasses (GBPUSD,M6) fast = 560 микросекунд, e = 568.39404456 , npoints = 1500 , nvars = 40
2018.06.27 04:36:53.737 TestClasses (GBPUSD,M6) slow = 813 микросекунд, e = 568.39404456 , npoints = 1500 , nvars = 40

I.e. you can see that the speed gain is more than 40%.

Files:
dataanalysis.mqh  1150 kb
TestClasses.mqh  2762 kb
 
Nikolai Semko:

Well, in essence, I'm sorry, but you're delusional.

No processor in existence today will ever

faster compared to...

and accessing an array will never be faster than accessing a simple variable,

three identical loops will never be faster than one combined loop.


I have not been lazy and tested the speed of two different variants directly in the original ALGLIB so as not to be unsubstantiated :

result:

I.e. you can see that the speed gain is more than 40%.

Thank you for the test! I think it will work faster not only in MQL, but in all languages.

The reasons I was thinking of were that the programmer who wrote it was not just paid for the program to work, but for the number of lines. For a program with 500 lines is not so impressive to a customer as a program with 5000 lines. It's a pity that the speed and readability of the code suffered because of it.

 
elibrarius:
I think it will work faster not only in MQL but in all languages.

Sure.

 
I noticed when logging into MQL there is an error and in the status of the browser there is a long answer (probably authorisation) from Facebook
 
SEM:

Synthetic tool. I import minute bars, each minute bar differs by 1 point (5 digits).

I close the window with symbols, then reopen this window, ask for minute bars from the previous load, I get

The symbols are the same for every full day. What is the error?

Is it playing steadily ? What build?

Reason: