5 digit broker shows 4 digit alert ?

 

Hi Guys/Girls,

I'm busy running my ea in demo account to take out some flaws...

One of them is the next one..

Ik make a calculation, and the results gives me a number with many digits.

As I use an Alert to show me the results, the Alert only shows me 4 digits. How can I see if my calculation was OK ?

I made an indicator and made some test runs with it, just to see the outcome on screen.

As you see, al outcomes never show me more as 4 digits. That is strange, cause the broker uses 5 digits price.

And you know what's strange too? The last 3 alerts must give me the same results, only calculated or represented differently.

However the first result of the last three gives me a zero?? I attached a screenshot of the code and the outcome of it.

How are those two things possible? can someone explain me if I am doing something wrong?

Thank you very much!!!

 

For alerts use

Alert(DoubleToStr(anyValue,anyNumberOfDigits));

If you let metatrader "decide" how to write out a double (in alert, print ... ) it will use 4 digits


The case with 0 is when you are dividing all integer values (12/78) and then metatrader does it as integer division

Use 12.0/78.0 instead and it will be OK (metatrader 4 does not have explicit type cast so you can not use something like (double)12/(double)78). That is one of the known "quirks" of metatrader and that is why you will often see a number+".0" in a code (just to make sure that metatrader does not "understand" some number wrongly)

 
 

Add result to string, then You will have result without rounding and errors. Then You can pritnt that - but still if You use it still will be rounding result.

Regards

Use 12.0/78.0 Use 12.0/78.0 instead and it will be OK

Still when You give as result double value. If You return result to integer value result will have error.

Reason: