trading tool with weird info box
-
Hey guys! So i created a trading tool where one can set pending orders using the edit field, directly on chart. This all works pretty well but in my pending order info box every time the price level is a plain number like 0.6300 it will show 0.63000001 in the box does anyone know why this happens? It doesnt happen with other numbers and messes with my info box structure Anyway i would really appreciate if someone can help me understand why this happens.
.link to project: https://fxdreema.com/shared/oumT1JtO
-
@fabien-s
I don't exactly know what causes this, I think it is something in the way computer uses floating point numbers... But there's a way to cut off the 5th digit and everything after it:MathFloor( var * 10000) / 10000
where var is whatever variable or function that you use to get that 0.6300 value.
Example:
MathFloor( 0.63000001 * 10000) / 10000 = 0.6300 -
@roar thanks for your reply!
Do you think it works if i put it in the Adjust field? In my case i would want to add (*10000/10000) or would this not work? or do i need to make my open price a variable first? -
@fabien-s
You have to apply the Floor function, so the adjust-field will not work...
So yeah, make it a variable first. The MathFloor function is like rounding, but only downwards. Here's the example in more detail:MathFloor( 0.63000001 * 10000) / 10000
= MathFloor( 6300.0001) / 10000
= 6300 / 10000
= 0.6300 -

Unless i have made a misstake with the implementation of the MathFloor function i think it doesnt work for my project, https://fxdreema.com/shared/NyjmMDpic
would you have implemented it the same way? -
@fabien-s Youre right, doesn't seem to work

-
@roar thanks for your time!