Digit Adjustment of Variable ** SOLVED **
-
Dear Friends,
I set value of a variable from an indicator, which provides 6 digits after point. This causes bid value comparison issue in EA.
For example:
I get value from indicator which sets variable:myVar=0.123456
bid= 0.12345How can I adjust digits of myVar to 0.12345?
I tried many things with no success...
Thank you.
-
I think this can be useful for you:
-
Hello @l-andorrà ,
Thank you very much for your reply.
I had seen that post. But what I need to do is to drop last digit. This code seems to get the last digit. Since I do not have programming knowledge I'm not sure if the mentioned post can be used to drop last digit.
I wonder if the value of variable can be modified at 'Adjust' field of the the block?
Any ideas @fxDreema ?
Regards.
-
Dear Friends,
After hours of search, I figured out how to solve this issue. Since I have NO programming knowledge, this simple problem became headache for me.
While I was searching similar issues in forum, I saw that most of the raised questions was not replied with a solution. I hope this info be useful to whom needs help on such topic.
I used 'Custom MQL code' block with the following code to have 5 digits after decimal point.

Problem solved!
Regards.
-
Impressive. Congratulations for your effort.

-
@l-andorrà Thank you! I've spent hours! Lack of knowledge is very bad :))))
Thanks again for your kind help on the subject.
Regards.
-
DoubleToStr() function takes a variable from "double" type and turns it into "string". "double" is a floating point number, while "string" is text. So it's not very correct what you are doing. Try NormalizeDouble() instead. The description of this function is like this: Rounding floating point number to a specified accuracy.
In Adjust there is some trick that you can do. You know that in Adjust you normally start with +, 0, * or /. But you can also do it like this:
= NormalizeDouble($, 5)When it starts with =, it's a little bit different. The final value will equal to whatever is on the right side of =. Well, I want to change the value that I got a little bit, not to give it a whole new value, so I use the value itself. That symbol $ is the value.
-
Hi @fxDreema ,
I have missed your solution on this subject. That's very informative.
It somehow worked for me but as you said I have to do it in the right way.
Thank you very much.
Regards.