MT5/mql5 reported and confirmed bugs. - page 4

 

Did not see it reported, so this one too :

It is from the "annoying" group - in a separate window if you have an EMPTY_VALUE in a buffer, it is still displayed after the indicator name as 0 (not omitted as it should be)


 
amrali #:

Binary-to-decimal conversion with minimal number of digits

Converting a double-precision binary floating-point number to a decimal string is a common operation,

but an algorithm producing results that are both accurate and minimal did not appear in print until
1990, with Steele and White's Dragon4. Some of the improvements since then include:

 - David M. Gay's dtoa.c, a practical open-source implementation of many ideas in Dragon4.

 - Grisu3, with a 4x speedup as it removes the use of bignums. Must be used with a fallback, as it fails for ~0.5% of cases.

 - Errol3, a complete algorithm similar to, but slower than, Grisu3.

 - Ryu, a complete algorithm that is faster and simpler than Grisu3.

Many modern language runtimes use Grisu3 with a Dragon4 fallback.


MQL5 implements a bad historic algorithm for conversion double -> str. That is why the forum is full of questions about floating point numbers weirdness.

Here is a proof of my point of view that it is as bug in the implementaion

That's not a bug. Case closed.

This topic is intended to report CONFIRMED bugs, not "point of view bug", please stop this discussion.

Thank you.

 
amrali #:

Bug in MQL string() function. Wrong conversion of double -> string

...

I reported it to Metaquotes anyway (not a bug in my opinion). They answered they will check if they can do something to improve it, so wait and see...

 
Actually it is not a pure bug. But it is a big source of confusion even for non-beginners.

Thanks Alain.

Edit:

I am providing another simple fix:

//+------------------------------------------------------------------+
//| Converting numeric value into the shortest decimal string that   |
//| round-trips into the same numeric value, double(Repr2(f)) == f.  |
//+------------------------------------------------------------------+
string Repr2(double value)
  {
   int decimalPlaces = 0;
   for(double p = 1; value != (MathRound(value * p) / p); p *= 10)
      decimalPlaces++;

   return StringFormat("%.*f", decimalPlaces, value);
  }
 

As far as I can make sense out of this, it should be considered a bug.

This shows to be true for a long time and still is, in indicators, when #property tester_indicator is set to the filename of the indicator, it will prevent the debugger from stopping at DebugBreaks set by inside the editor as well as the function DebugBreak().

#property tester_indicator "filename_here.ex5"

int OnInit()
{
        DebugBreak(); // <- Wont halt inside the debugger
        return(INIT_SUCCESS);
}

This is also true for debug stops set inside the Editor.



Will be ignored.


Only fix at the moment is to comment the property...


//#property tester_indicator "filename_here.ex5"


I ask myself why this  has never been reported before.

 
Dominik Christian Egert #:

As far as I can make sense out of this, it should be considered a bug.

This shows to be true for a long time and still is, in indicators, when #property tester_indicator is set to the filename of the indicator, it will prevent the debugger from stopping at DebugBreaks set by inside the editor as well as the function DebugBreak().

This is also true for debug stops set inside the Editor.



Will be ignored.


Only fix at the moment is to comment the property...



I ask myself why this  has never been reported before.

Sorry but that's unclear. Please provide ALL the code and procedure to reproduce it.
 
Alain Verleyen #:
Sorry but that's unclear. Please provide ALL the code and procedure to reproduce it.

Ive added the property to this file, its the sample from the original installation of MT5.


You will need to edit the file, set a Debug Stop on any line inside the file.

It wont hold/stop if the property is set.

It will, if its not set.


#property tester_indicator "BB.ex5"
Files:
BB.mq5  6 kb
 
Dominik Christian Egert #:

Ive added the property to this file, its the sample from the original installation of MT5.


You will need to edit the file, set a Debug Stop on any line inside the file.

It wont hold/stop if the property is set.

It will, if its not set.


What's the point of this instruction in the indicator itself ? Doesn't make sense.
 
The documentation says this:

Name of a custom indicator in the format of "indicator_name.ex5". Indicators that require testing are defined automatically from the call of the iCustom() function, if the corresponding parameter is set through a constant string. For all other cases (use of the IndicatorCreate() function or use of a non-constant string in the parameter that sets the indicator name) this property is required.

"For all other cases [...] this property is required."

How do I have to understand this?


 
Dominik Christian Egert #:
The documentation says this:

Name of a custom indicator in the format of "indicator_name.ex5". Indicators that require testing are defined automatically from the call of the iCustom() function, if the corresponding parameter is set through a constant string. For all other cases (use of the IndicatorCreate() function or use of a non-constant string in the parameter that sets the indicator name) this property is required.

"For all other cases [...] this property is required."

How do I have to understand this?


How ? The better is to understand it correctly

You don't need to use this statement in the indicator itself, you need to use it in OTHER codes that use this indicator, and ONLY if needed (dynamic indicator name).