BUG REPORT: String size limit for inputs in optimizations

 
string A="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
// The string above has 200 characters
input int B=0;

int OnInit()
  {
   return(INIT_SUCCEEDED);
  }
double OnTester()
  {
   // Just return the character count
   return StringLen(A);
  }

If I run a backtest of the EA above the OnTester result is 200.

If I run an optimization of the "B" input (the values don't matter, it's used so I can do an optimization) the result is also 200.


So far so good.


Now let's  transform the "A" variable in an input.

input string A="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
// The string above has 200 characters
input int B=0;

int OnInit()
  {
   return(INIT_SUCCEEDED);
  }
double OnTester()
  {
   // Just return the character count
   return StringLen(A);
  }

Now If I run a backtest of the EA above the OnTester result is 200, as expected.

Nothing fancy till here.


But If I run an optimization of the "B" input the result is 63.


It start happening in the latest build, so looks like is was introduced an string size limit to string input parameters that affects only optimizations. I don't think is was intentional.

Is very weird to have the same EA generating different results for a single backtest vs an optimization with exactly the same inputs.

If you (Metaquotes) want to cap the string size you should limit the size of the string that the user can type. 


Thank you.

 

Hi,

Base on this documentation as you can find out :

https://docs.mql4.com/basis/variables/externvariables

Note: The length of a string comment for extern variables cannot exceed 63 characters.

Extern Variables - Variables - Language Basics - MQL4 Reference
Extern Variables - Variables - Language Basics - MQL4 Reference
  • docs.mql4.com
Similar to input-variables, extern ones also determine the input parameters of an mql4 program. They are available from the Properties window. Unlike input variables, values of extern variables can be modified in the program during its operation. External variables are always reinitialized...
 

Mehrdad Jeddi:

Note: The length of a string comment for extern variables cannot exceed 63 characters.

 "The length of a string comment..."

Thank you, but I'm not talking about the comment. I'm talking about the string value / content. 

 

Forum on trading, automated trading systems and testing trading strategies

Errors, bugs, questions

Slava , 2019.03.26 11:39

The fact that in a single test is not truncated to 63 characters, it is just an accident.

The length of the input parameter of type string must not exceed 63 characters (64 together with a null terminator)


 

Unbelievable.

I feel like I'm back in time programming for a PC XT. :)

Thank you @Alain Verleyen!

 
Henrique Vilela:

 "The length of a string comment..."

Thank you, but I'm not talking about the comment. I'm talking about the string value / content. 

Yes,i know,but the full expression is  :

"The length of a string comment for extern variables cannot exceed 63 characters."

 
Mehrdad Jeddi:

Yes,i know,but the full expression is  :

"The length of a string comment for extern variables cannot exceed 63 characters."

That's not the point.The key word there is "comment".


The documentation only says it has a limit to the comment, not to the content / value.

input string var_name = "Content / value"; // Comment
 
Henrique Vilela:

That's not the point.The key word there is "comment".


The documentation only says it has a limit to the comment, not to the content / value.

No,Comment is not important,the comment can be more than 2k lines and words !

The doc means the variable name comment,as you checked it in your backtesting with the "input string A" variable and see the "StringLen(A)"

returns the maximum valid value for extern input parameter was 63 characters !

 
Mehrdad Jeddi:

No,Comment is not important,

Yes, it is. Comment define the input label in the input interface.

Mehrdad Jeddi:

the comment can be more than 2k lines and words !

The comment on the code of course can be as long as I want...

But It'll be truncated to 63 characters in the interface as the documentation says.


Look:

input string A=""; // ABCDEFGHIJKLMNOPQRSTUVXYWZ ABCDEFGHIJKLMNOPQRSTUVXYWZ ABCDEFGHIJKLMNOPQRSTUVXYWZ



Let's read again what the documentation says:

"The length of a string comment for extern variables cannot exceed 63 characters."


So, the documentation explains the result above (the truncated comment / label is expected).

But the string content / value limit is not explained in the documentation,

it's explained (or at least justified) only in the @Slava post in this forum shared here by @Alain Verleyen 

 
Henrique Vilela:

Yes, it is. Comment define the input label in the input interface.

The comment on the code of course can be as long as I want...

But It'll be truncated to 63 characters in the interface as the documentation says.


Look:



Let's read again what the documentation says:

"The length of a string comment for extern variables cannot exceed 63 characters."


So, the documentation explains the result above (the truncated comment / label is expected).

But the string content / value limit is not explained in the documentation,

it's explained (or at least justified) only in the @Slava post in this forum shared here by @Alain Verleyen 

So as you see it doesnt allow more than 63characters as their docs,and you see in backtest mode by StringLen() function !

So it's not bug,it's limited by their expected.

 
Mehrdad Jeddi:

So as you see it doesnt allow more than 63characters as their docs

No.

The documentation is about the comment my problem is about the content.

COMMent. CONTent.

input string var_name = "CONTENT"; // COMMENT

But yes, it is not a bug, it is expected.

Not because it's in the documentation (it's not) but because @Slava (who I guess is from the dev team) say so.


But thank you anyway for your contribution.