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!
What is the correct way to use "double" in the "for" loop? There seems to be no prohibition on using "double" in the help.
Anyway, my conclusion is that "double" is not recommended in the"for" loop because of lack of normalization of ExpressionZ after each iteration. This can lead to at least 2 problems:
1) Wrong number of iterations;
2) Wrong results if you use ExpressionZ to calculate in a statement.
Thank you, I understand why this happens, that's why I tried to normalise. It didn't work for me. Alexey Viktorov option didn't fix it either, values remain non-normalized. So the question remains, can "double" be used in a loop and always get the correct number of iterations?
Multiply by 10 to the right degree until you get integers. At first I struggled too, now I even convert price to integers and work with integers or rounding to integers. I have fewer errors, better readability.
In general, as one programmer said after receiving summaries from the Exchange, I do not understand why numbers of a certain digit capacity are represented by real numbers, rather than integers. This is not logically correct. ))))
Multiply by 10 to the right degree until you get integers. At first I struggled too, but now I even convert the price to an integer and work with integers or rounding to integers. I have fewer errors, better readability.
In general, as one programmer said after receiving summaries from the Exchange, I do not understand why numbers of a certain digit capacity are represented by real numbers, rather than integers. This is not logically correct. ))))
Thanks, I'll use int in the old way and then divide by double. ;)
Thanks, but your example didn't give the right result either. In printf you can see that no normalisation takes place:
Sorry, I should have checked it. And here we have "I wanted to do it right, but it turned out to be the same as always".
Result
Correct code
Correct code
Be careful not to put step=0.04 ;)
Be careful not to put step=0.04 ;)
This is only advice for those who don't know how to use their brains.)))
Sorry, I should have checked. It's just, "I meant well, but it's always the same."
Result
Correct code.
i=NormalizeDouble(i+step, 1)
Ah, thank you! I didn't think of it myself. That's just the kind of thing that helps us newbies in programming! ;)
I'm looking formethods to sort an array of structures. Does anyone have any working variants ?
https://www.mql5.com/ru/forum/170952/page134#comment_11532251
https://www.mql5.com/ru/forum/170952/page134#comment_11532251
It doesn't work...