
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
SDC:
I decided to mathround the prices to round out those offending decimal places so I modified the test script:
[code not copied; see above]
output:
EURUSD,M1: Alert: 263452 prices checked
EURUSD,M1: Alert: 263452 prices passed test
EURUSD,M1: Alert: 0 prices failed test
I agree with the output from your second test. MathRound() and NormalizeDouble() do relatively same thing. MathRound takes a double and rounds that double to the nearest integer. NormalizeDouble takes a double and rounds that double to a specified decimal precision. So, MathRound(1.23) == 1.00 but NormalizeDouble(1.23, 1) == 1.20. Both values are rounded, but just in different places depending on the precision value given to NormalizeDouble(). Another example is: MathRound(1.23*10)/10 == NormalizeDouble(1.23, 1).
i did some more testing. Someone earlier on this thread said WHR is overly critical of NormalIzeDouble() I can tell you he is not overly critical at all. NormalizeDouble() is not accurate.
[code not copied; see above]
You would expect NormalizeDouble() to round that up to 1.2322 right ? Run that script it and see what it does. The Alert says 1.2322 so you all say what are you talking about SDC that worked fine. No it didnt. If you convert that double to integer it will remove any decimal places from it and reveal if the double is really 1.2322 or is it not ? So now run this script.
[code not copied; see above]
output
EURUSD,M1: Alert: normalized 1.2322 = 1.2322
EURUSD,M1: Alert: test = 12321
NormalizeDouble() never did round it properly, the resulting double was less than 1.2322
NormalizeDouble() works correctly. The problem you are seeing is derived from dividing by Point. If you multiply by 10000, rather than dividing by Point, you get the correct anoswer:
See the following side-by-side test:
Output:
Open: 1.23219900 Normalized: 1.23220000 UnroundedInteger: 123219 RoundedInteger: 123220 NormalizedToInteger1: 123219 NormalizedToInteger2: 123220
Yes you are right NormalizeDouble() does work correctly, my test parameters were not valid, I removed that previous post to avoid causing confusion.
I should have done integer = NormalizeDouble(1.232199/Point,0);