Errors, bugs, questions - page 2164

 
Vladimir Pastushak:

There is very little space in product descriptions.

3600 characters is extremely short for large and serious programmes.

I think many people will agree with me.

You need not less than 5000 - 10000 characters for describing programs. Or at least a tab with the name of the program settings

A moderator can always ask to remove the water.

Right now I'm writing a description of the programme, and I've used all 3,600 characters just to describe the settings, but I haven't even described half of the features...

Vladimir, have you ever bought anything? How much time have you spent reading the manual?

No one is going to read a multi-volume book, and they won't even watch videos longer than 3-5 minutes.
There is only one solution: Tooltips in the interface of the programme, as almost everywhere else does. Something like an interactive tutorial. And detailed instructions for advanced users can be placed in a blog or on their site. Whoever wants it will find it and download it.

 
Vladimir Pastushak:

There is very little space in product descriptions.

3600 characters is extremely short for large and serious programmes.

I think many people will agree with me.

You need not less than 5000 - 10000 characters for describing programs. Or at least a tab with the name of the program settings

A moderator can always ask to remove the water.

Right now I'm writing a description of the programme, I've used all 3,600 characters just to describe the settings and not even half of the features...

I don't agree. Brevity is the sister of talent.

"Do not think that in your many words you will be heard."

Matthew 6:7.

 
Andrey Khatimlianskii:

Vladimir, have you ever bought anything? How much time have you spent reading the instructions?

No one will read a multi-volume book, they won't even watch a video 3 to 5 minutes long.
There is only one way out - to add hints in the interface of the programme, as is done almost everywhere now. Something like an interactive tutorial. And detailed instructions for advanced users can be placed in a blog or on their site. Whoever wants it will find it and download it.

Those who don't read and don't buy, have you bought many products without understanding what the product is for?

Should we publish everything on blogs then?

 
Nikolai Semko:

I disagree. Brevity is the sister of talent.

"Do not think that in your verbosity you will be heard."

Matthew 6:7.

I agree, but even brief 3600 is not enough...

 
Vladimir Pastushak:

Those who don't read and don't buy, have you bought many products without understanding what the product is for?

Should we publish everything on blogs then?

Understand the purpose of the product from the manual?

That's silly. I'll download and feel the demo.

 
A100:

This code is based on a compiler defect

Result: 1... Why not 2 ?

While C++ reports an error during compilation, because both functions obviously fit, and besides, the syntax does not allow explicitly calling the function (2)

Moreover, taking into account specific features of MQL, it would be more logical to do the opposite - to set the priority of passing the parameter not by value (as now), but by const reference (benefits of which are especially evident in the example of strings).

void f(       string  ) { Print( __FUNCSIG__ ); } //1
void f( const string& ) { Print( __FUNCSIG__ ); } //2
string g() { return "ABCDEF4"; }
void OnStart()
{
          string text1 = "ABCDEF1";
    const string text2 = "ABCDEF2";
//  вызываемая функция: сейчас  предлагается
    f( text1 );     //    1       2               
    f( text2 );     //    *       2 потому что const или оставить *
    f( "ABCDEF3" ); //    1       1
    f( g());        //    1       1
//Примечание: * - неопределенность
}

It is unclear why to pass (actually copy) long strings by value when it can be done by reference.

 

Compilation error

#import  "Test.dll" //Error: '#import' - #import was not closed
#include "Test.h"
#import
//Test.h
void f();

Why manually move the contents of the .h file (especially since it can change from time to time) when you can just include it?

 

Good afternoon, could you please advise:

How to writethe optimization results in a file using Local Network Farm or MQL5 Cloud Network ?

There is a procedure in OnTester(), uses:

string toWrite = "test";
fileHandle=FileOpen(fileName,FILE_CSV|FILE_READ|FILE_WRITE|FILE_ANSI|FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_COMMON,",");
FileWrite(fileHandle,toWrite);
FileClose(fileHandle);

When using Local agents, the file with optimization results is created in the shared folder, when using Local Network Farm or MQL5 Cloud Network, there is no file.

Тестирование стратегий - Алгоритмический трейдинг, торговые роботы - MetaTrader 5
Тестирование стратегий - Алгоритмический трейдинг, торговые роботы - MetaTrader 5
  • www.metatrader5.com
Тестер стратегий позволяет тестировать и оптимизировать торговые стратегии (советники) перед началом использования их в реальной торговле. При тестировании советника происходит его однократная прогонка с начальными параметрами на исторических данных. При оптимизации торговая стратегия прогоняется несколько раз с различным набором параметров...
 
Nikolai Semko: WHAT IS WRONG? WHERE IS THE SLOWDOWN COMING FROM?

A check revealed that:

  1. SQRT mappings into direct CPU instructions

  2. SQRT + math calculations go without branches and one instruction (128 bits of data) calculates two roots at once

    This code turns into the following assembler SSE code:
             D1=sqrt((X1-X)*(X1-X)+(Y1-Y)*(Y1-Y));
             D2=sqrt((X2-X)*(X2-X)+(Y2-Y)*(Y2-Y));
             D3=sqrt((X3-X)*(X3-X)+(Y3-Y)*(Y3-Y));
             D4=sqrt((X4-X)*(X4-X)+(Y4-Y)*(Y4-Y));
             D5=sqrt((X5-X)*(X5-X)+(Y5-Y)*(Y5-Y));
             D6=sqrt((X6-X)*(X6-X)+(Y6-Y)*(Y6-Y));
             D7=sqrt((X7-X)*(X7-X)+(Y7-Y)*(Y7-Y));
             D8=sqrt((X8-X)*(X8-X)+(Y8-Y)*(Y8-Y));
            ...
            sqrtsd  xmm1, xmm1
            unpcklpd        xmm4, xmm4
            movapd  xmm3, xmmword ptr [rsp + 432]
            unpcklpd        xmm3, xmmword ptr [rsp + 384]
            subpd   xmm3, xmm4
            mulpd   xmm3, xmm3
            unpcklpd        xmm0, xmm0
            movapd  xmm5, xmmword ptr [rsp + 416]
            unpcklpd        xmm5, xmmword ptr [rsp + 400]
            subpd   xmm5, xmm0
            mulpd   xmm5, xmm5
            addpd   xmm5, xmm3
            sqrtpd  xmm8, xmm5
            movapd  xmm5, xmmword ptr [rsp + 464]
            subpd   xmm5, xmm4
            mulpd   xmm5, xmm5
            movapd  xmm7, xmm9
            subpd   xmm7, xmm0
            mulpd   xmm7, xmm7
            addpd   xmm7, xmm5
            movapd  xmm6, xmm10
            unpcklpd        xmm6, xmm11
            subpd   xmm6, xmm4
            movapd  xmm3, xmmword ptr [rsp + 368]
            unpcklpd        xmm3, xmmword ptr [rsp + 352]
            subpd   xmm3, xmm0
            movapd  xmm4, xmm8
            shufpd  xmm4, xmm4, 1
            sqrtpd  xmm5, xmm7
            mulpd   xmm6, xmm6
            mulpd   xmm3, xmm3
            addpd   xmm3, xmm6
            sqrtpd  xmm15, xmm3
            movapd  xmm0, xmm14
            unpcklpd        xmm0, xmmword ptr [rsp + 336]
            subpd   xmm0, xmm2
            mulpd   xmm0, xmm0
            movapd  xmm2, xmm0
            shufpd  xmm2, xmm2, 1
            addsd   xmm2, xmm0
            movapd  xmm0, xmm15
            shufpd  xmm0, xmm0, 1
            sqrtsd  xmm12, xmm2
    This is a work of art actually. 8 roots were calculated in 4 calls of an assembler instruction. Two double numbers are evaluated in one call.

  3. When operating through an array, everything goes as usual with checks, branching and losses on converting the double -> integer index.

  4. When working with arrays in this example there's constant FPU/ALU mixing which is very bad for productivity

  5. Optimization of dynamic array access is great - beyond praise. But mixing FPU/ALU operations + double -> integer + branching wastes time

The overall conclusion: mathematics in MQL5 wins due to perfect optimization. It's not arrays that lose here, but mathematics wins.

 

And here's what pornography was made on the same code by Visual C++ 2017 x64 with full optimizations:

; 52   :       int X=pos%Width;
; 53   :       int Y=int(pos/Width);
; 54   :       
; 55   :       D1=sqrt((X1-X)*(X1-X)+(Y1-Y)*(Y1-Y));

  0046 f 0 f 28 c8         movaps  xmm1, xmm0
  00472 8 b c3            mov     eax, ebx
  00474 99               cdq
  00475 45 0 f 57 db      xorps   xmm11, xmm11
  00479 f7 ff            idiv    edi
  0047 b 0 f 57 f6         xorps   xmm6, xmm6
  0047 e 41 0 f 28 c4      movaps  xmm0, xmm12
  00482 f2 44 0 f 2 a d8   cvtsi2sd xmm11, eax
  00487 f2 0 f 2 a f2      cvtsi2sd xmm6, edx
  0048 b f2 41 0 f 5 c cb   subsd   xmm1, xmm11
  00490 f2 0 f 5 c c6      subsd   xmm0, xmm6
  00494 f2 0 f 59 c9      mulsd   xmm1, xmm1
  00498 f2 0 f 59 c0      mulsd   xmm0, xmm0
  0049 c f2 0 f 58 c1      addsd   xmm0, xmm1
  004 a0 e8 00 00 00 00   call    sqrt

; 56   :       D2=sqrt((X2-X)*(X2-X)+(Y2-Y)*(Y2-Y));
; 57   :       D3=sqrt((X3-X)*(X3-X)+(Y3-Y)*(Y3-Y));

  004 a5 41 0 f 28 cf      movaps  xmm1, xmm15
  004 a9 41 0 f 28 c6      movaps  xmm0, xmm14
  004 ad f2 0 f 5 c c6      subsd   xmm0, xmm6
  004 b1 f2 41 0 f 5 c cb   subsd   xmm1, xmm11
  004 b6 f2 0 f 59 c0      mulsd   xmm0, xmm0
  004 ba f2 0 f 59 c9      mulsd   xmm1, xmm1
  004 be f2 0 f 58 c1      addsd   xmm0, xmm1
  004 c2 e8 00 00 00 00   call    sqrt

; 58   :       D4=sqrt((X4-X)*(X4-X)+(Y4-Y)*(Y4-Y));

  004 c7 f2 0 f 10 8 c 24
        90 01 00 00      movsd   xmm1, QWORD PTR Y4$1$[rsp]
  004 d0 f2 0 f 10 84 24
        98 01 00 00      movsd   xmm0, QWORD PTR X4$1$[rsp]
  004 d9 f2 41 0 f 5 c cb   subsd   xmm1, xmm11
  004 de f2 0 f 5 c c6      subsd   xmm0, xmm6
  004 e2 f2 0 f 59 c9      mulsd   xmm1, xmm1
  004 e6 f2 0 f 59 c0      mulsd   xmm0, xmm0
  004 ea f2 0 f 58 c1      addsd   xmm0, xmm1
  004 ee e8 00 00 00 00   call    sqrt

; 59   :       D5=sqrt((X5-X)*(X5-X)+(Y5-Y)*(Y5-Y));
; 60   :       D6=sqrt((X6-X)*(X6-X)+(Y6-Y)*(Y6-Y));
; 61   :       D7=sqrt((X7-X)*(X7-X)+(Y7-Y)*(Y7-Y));
; 62   :       D8=sqrt((X8-X)*(X8-X)+(Y8-Y)*(Y8-Y));

  004 f3 f2 0 f 10 44 24
        20               movsd   xmm0, QWORD PTR X8$1$[rsp]
  004 f9 41 0 f 28 c8      movaps  xmm1, xmm8
  004 fd f2 0 f 5 c c6      subsd   xmm0, xmm6
  00501 f2 41 0 f 5 c cb   subsd   xmm1, xmm11
  00506 f2 0 f 59 c0      mulsd   xmm0, xmm0
  0050 a f2 0 f 59 c9      mulsd   xmm1, xmm1
  0050 e f2 0 f 58 c1      addsd   xmm0, xmm1
  00512 e8 00 00 00 00   call    sqrt
  00517 f2 0 f 10 4 c 24
        28               movsd   xmm1, QWORD PTR Y2$1$[rsp]
  0051 d 41 0 f 28 c5      movaps  xmm0, xmm13
  00521 f2 44 0 f 10 44
        24 30            movsd   xmm8, QWORD PTR Y5$1$[rsp]
  00528 f2 41 0 f 5 c cb   subsd   xmm1, xmm11
  0052 d f2 44 0 f 10 54
        24 40            movsd   xmm10, QWORD PTR Y6$1$[rsp]
  00534 f2 0 f 5 c c6      subsd   xmm0, xmm6
  00538 f2 44 0 f 10 64
        24 50            movsd   xmm12, QWORD PTR Y7$1$[rsp]
  0053 f f2 45 0 f 5 c c3   subsd   xmm8, xmm11
  00544 f2 0 f 10 7 c 24
        38               movsd   xmm7, QWORD PTR X5$1$[rsp]
  0054 a f2 45 0 f 5 c d3   subsd   xmm10, xmm11
  0054 f f2 44 0 f 10 4 c
        24 48            movsd   xmm9, QWORD PTR X6$1$[rsp]
  00556 f2 45 0 f 5 c e3   subsd   xmm12, xmm11
  0055 b f2 44 0 f 10 5 c
        24 58            movsd   xmm11, QWORD PTR X7$1$[rsp]
  00562 f2 0 f 5 c fe      subsd   xmm7, xmm6
  00566 f2 0 f 59 c0      mulsd   xmm0, xmm0
  0056 a f2 44 0 f 5 c ce   subsd   xmm9, xmm6
  0056 f f2 0 f 59 c9      mulsd   xmm1, xmm1
  00573 f2 44 0 f 5 c de   subsd   xmm11, xmm6
  00578 f2 0 f 58 c1      addsd   xmm0, xmm1
  0057 c e8 00 00 00 00   call    sqrt
  00581 f2 0 f 59 ff      mulsd   xmm7, xmm7
  00585 f2 45 0 f 59 c0   mulsd   xmm8, xmm8
  0058 a f2 41 0 f 58 f8   addsd   xmm7, xmm8
  0058 f 0 f 28 c7         movaps  xmm0, xmm7
  00592 e8 00 00 00 00   call    sqrt
  00597 f2 45 0 f 59 c9   mulsd   xmm9, xmm9
  0059 c f2 45 0 f 59 d2   mulsd   xmm10, xmm10
  005 a1 f2 45 0 f 58 ca   addsd   xmm9, xmm10
  005 a6 41 0 f 28 c1      movaps  xmm0, xmm9
  005 aa e8 00 00 00 00   call    sqrt
  005 af f2 45 0 f 59 db   mulsd   xmm11, xmm11
  005 b4 f2 45 0 f 59 e4   mulsd   xmm12, xmm12
  005 b9 f2 45 0 f 58 dc   addsd   xmm11, xmm12
  005 be 41 0 f 28 c3      movaps  xmm0, xmm11
  005 c2 e8 00 00 00 00   call    sqrt
  005 c7 f2 0 f 10 84 24
        88 01 00 00      movsd   xmm0, QWORD PTR Y1$1$[rsp]

; 63   : 
; 64   :       double d=fabs(D1+D3+D4+D8)/(D1+D2+D3+D4+D5+D6+D7+D8);

An unqualified multiple of the code generated in MQL5.

Surprisingly, MSVC doesn't even try to optimize - all mathematics is driven through libraries as if it was written for a 20 year old processor. And enabling AVX commands set doesn't change the compiler's behavior at all.

Test C++ file attached. There is no error in the test example, so don't express the thought about "an error in the test example".

Files:
Test.cpp.zip  1 kb