BenLinus:
Isn't it because -1*Logb(10,0.01) is cast to an int and Logb(10,0.01) is 1.9999999xxxxx ? try ( -1 * Logb(10,0.01)) + 0.5 or use MathCeil()
Hello,
In the first case, why didn't pres get assigned the value of -1*Logb(10,0.01) correctly?
int = (...) + 0.5 or int = MathRound(...)
MathRound() does the trick. So, it is probably as RaptorUK said: Logb(10,0.01) = 1.9999999....
But it doesn't make sense to me why the output of Alert() says: -Logb(10,0.01) = 2.00000000. Maybe it rounds it on its own.
Thanks.
BenLinus:
...
But it doesn't make sense to me why the output of Alert() says: -Logb(10,0.01) = 2.00000000. Maybe it rounds it on its own.
Looks like the number gets rounded in the 9th decimal place.
Alert("Alert test #1: " + 1.99999999); Alert("Alert test #2: " + 1.999999999); Alert("Alert test #3: " + 1.999999991); Alert("Alert test #4: " + 1.999999995);
Thirteen:
Looks like the number gets rounded in the 9th decimal place.
Yes. So, this was the culprit. Thanks
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello,
Does anyone understand this weird behaviour bellow:
Output:
2013.08.24 08:44:48 me EURJPY.,H1: Alert: LotSize = 1.11611000, -Logb(10,0.01) = 2.00000000, pres = 1, norm = 1.10000000
But if I do this:
Output:
2013.08.24 08:46:37 me EURJPY.,H1: Alert: LotSize = 1.11611000, -Logb(10,0.01) = 2.00000000, pres = 2, norm = 1.12000000
In the first case, why didn't pres get assigned the value of -1*Logb(10,0.01) correctly?