Rounding Account Balance*
-
Hi Dreemas*
I want to round the account balance to 2 decimal places and put that into a variable...
Any maths wizards out there who would know which formula to use to do that...?
Example: 570.632563 becomes 570.63
Regards*
-
DoubleToString(570.632563,2);
This is rough and depends on where you add, you can use a variable name for your number...
-
@jstap said in Rounding Account Balance*:
DoubleToString(570.632563,2);
So in Formula block, formula is Account Balance > ?
Regards*
-
Yes add a link, or a picture showing what you mean if not working for you.
-
So what would be the formula here...?

-
Ok, so you want balance +1 which will make almost no difference?
I would do this:
DoubleToString(AccountBalance(),2)+1 in left operand (you can add as text code input encase)
+
0 in right operandThis should save into your variable
-
No....I want to round the account balance to 2 decimal places and put that into the variable....
Coz as you know, sometimes the account balance in MT4 shows as 570.632839273....for example....But I don't know which formula would round it down to 2 decimal places....
There must be a way because it does it in the Comment Block.... :.)
-
@jstap said in Rounding Account Balance*:
DoubleToString(AccountBalance(),2)+1 in left operand
How would I put that in the Formula block....? :.D
-
I think I'm in over my head here....

-
Not sure exactly what you need, but this would do it:

-
Well I can try that thanks....
So we're not even using the Formula Block then....*
-
@jstap said in Rounding Account Balance*:
Not sure exactly what you need, but this would do it:


-
It shouldn't as it always worked for me, I see that it has worked for equity. I know of nothing else you could try...
-
It didn't work for Equity....It just happened to be that way. If a trade were to open Equity would print 10 decimal places too.... :.)
Must be a way coz as I said, BossMan Dreema did it when he coded the Comment Block....
Appreciate the help....*
-
Does it prink 10 initially then revert to 2? if so it is just taking a second to work. I don't know about FX but he was the one that said about DoubleToString
-
Yes that seems to be what happens. So when you have trades open, the Equity is constantly changing....
So it's not perfect and it's still pretty ugly, but yes your code does seem to work...Regards*