MetaTrader 5 build 2121: New design of the Strategy Tester - page 7

 
Roman:

Added StringLen to the test, and initialized the string differently. The documentation says one thing, the actual behavior is different.
And buffer in this case shows 0 instead of 260.

The documentation specifies when 0 is returned and it is appropriate for the specified case

 
A100:

The documentation indicates when 0 is returned and is appropriate for the case indicated

The documentation does not match the current behaviour at all!

What is the difference between the two types of initialisation?

StringInit(str, 1, "_");
string str = "_";
And the results are different ))
And it's not clear where the left number 260 is coming from.
 
Roman:

The documentation does not match the current behaviour at all!

Documentation: A value of 0 means that the string is a constant and the contents of the buffer cannot be changed.

The string is initialized with constant "_" and the compiler considers the string conditionally (for efficiency purposes) a constant - why not? Why is there a contradiction? All the more so because no further operations are performed with it.

 
Roman:
And in general it is not clear where the left number 260 is coming from.

The moderator explained where it came from, and why it in the case of

string str = "_";

does not appear - reason to check

 
A100:

The moderator clarified where from

I think I got it with number 260, the compiler itself allocates the initial size of theStringBufferLen buffer to 260.
If the string length is less than 260, the StringBufferLen will print 260, not the actual string length!
And if the string length is greater than 260, then the actual string value is printed.

So, using the StringBufferLen function, with a string length of less than 260 characters, we won't get the actual string length, and will always get 260.
This must be an error.
As soon as the length exceeds 260 characters, we will get the real string length.

p.s. as the documentation is out of date it is very misleading.

 
Roman:

That is, using the StringBufferLen function, with a string length of less than 260 characters, we will not get the actual string length, and will always get 260.
This must be an error.
As soon as the length exceeds 260 characters, we will get the real length.

Strictly speaking string length: StringLen and buffer length: StringBufferLen are rather rare functions. And in general they may not coincide.

That makes two at least questionable cases:

void OnStart() 
{ 
        string s1 = "_";
        Print(StringBufferLen(s1)); //(1)//Ожидалось 260 вместо 0 - строка s1 далее может быть увеличена
        StringInit(s1,1,'_');
        const string s2 = s1;
        Print(StringBufferLen(s2)); //(2)//Ожидалось 0\1 вместо 260 - строка s2 константная и не может быть далее увеличена
}
 
まだ、ストラテジーテスターのオプティマイズの不具合が修正されていません。
修正してください。
私が使っている最適化設定は、バランス+シャープレシオですが、スクリーンショットの画像のように、異常な最適化数値が表示され、以降の最適化のジェネレーションにこの異常値による正常な最適化が不可能になっています。

To MetaQuotes Software Corp.
The strategy tester optimization bug has not been fixed yet.
Please correct.
The optimization setting I use is balance + sharp ratio, but an abnormal optimization value is displayed as in the screenshot, and normal optimization due to this abnormal value is generated in the subsequent optimization generation. It is impossible.

The error in the strategy tester's optimization is not yet fixed.
Please fix it.
The optimization I'm using is balance + sharp, but the abnormal optimization value is shown as in the screenshot and normal optimization due to this abnormal value is generated in subsequent optimization generation. This is not possible
 
The string length is StringLen. And StringBufferLen shows the preallocated memory size.

The preallocated string memory size is an internal matter of the compiler and should not be set on it.
 
Renat Fatkhullin:
The preallocated string memory size is an internal matter of the compiler and you cannot rely on it.

The executionresults show that the compiler acts contrary to logic:

  • For a constant string more memory is allocated than necessary (its length cannot be increased in principle)
  • For a non-constant string, no additional memory is allocated (if its length is increased, a new memory allocation will be required)
  • If a user initializes a string with StringInitInit, more memory is allocated than needed, because the buffer size is explicitly set by the user and in most cases it won't be increased (the user has already thought about what final buffer he needs and set its size explicitly)
 
A100:

The executionresults show that the compiler acts contrary to logic:

  • For a constant string more memory is allocated than necessary (its length cannot be increased in principle)
  • For a non-constant string, no additional memory is allocated (if its length is increased, a new memory allocation will be required).
  • If a user initializes a string with StringInitInit, more memory is allocated than necessary, because the buffer size is defined explicitly by the user, and in most cases, it will not be increased (the user has already thought about what final buffer he needs and defined its size explicitly)

Preallocation size of buffers for strings is an internal matter of the compiler.

We will change the handling of strings many more times.