Features of the mql4 language, subtleties and techniques - page 29
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
Is the time the same in theData window?
Yes.
Yes.
I see. So it really is the bar time. I just had a suspicion about the"Precise timeline" parameter.
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. I understand that I have to normalize " i ", but it doesn't work for me.
If "expr2=2.6" is still ok for 9 iterations, but when "expr2=2.8" is already showing 9 iterations wrong (the correct value is 10).
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. I understand that I have to normalize " i ", but it doesn't work for me.
If "expr2=2.6" is still fine for 9 iterations, but when "expr2=2.8" is already showing incorrect 9 iterations (the correct value is 10).
I probably need to normalize the values.
Probably need to normalise the values.
If you meant this way, it didn't help either:
If you meant this way, it didn't help either:
No. At the very least you have to optimise it
because that's what gives you the wrong value. And the others may not have to.
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. I understand that I have to normalize " i ", but it doesn't work for me.
If "expr2=2.6", then all is normal 9 iterations, but when "expr2=2.8" shows not correct 9 iterations (correctly 10).
Here you can find, read Nikolay's post, very detailed and very qualitative description of doublehttps://www.mql5.com/ru/forum/1111/page2623#comment_14473837
If you cannot assimilate the material from the first time, try to replace Print() with printf() in your code with output of double at least to 15-th digithttps://www.mql5.com/ru/forum/1111/page2623#comment_14474138.
Maybe then you will see why this is so
No. At the very least you have to optimise this
because that's what gives you the wrong value. And the others may not have to.
Thank you, but your example didn't give us the right result either. In printf you can see that no normalization happens:
0 10:29:31.595 Test_Double_For EURCHF,H4: i = 1.0000000000000000000000000000000000000000000000000000000000
0 10:29:31.595 Test_Double_For EURCHF,H4: i = 1.199999999999999999995559107901499373838305473327636718750000
0 10:29:31.595 Test_Double_For EURCHF,H4: i = 1.399999999999991111182158029987476766109466552734375000000000
0 10:29:31.595 Test_Double_For EURCHF,H4: i = 1.5999999999999999999866773237044981212151491164199829101562500000000
0 10:29:31595 Test_Double_For EURCHF,H4: i = 1.799999999999999999982236431605997495353221893310546875000000
0 10:29:31.595 Test_Double_For EURCHF,H4: i = 1.9999999999999997779553950749686919152736638618359375000000
0 10:29:31.595 Test_Double_For EURCHF,H4: i = 2.1999999999999997335464740899624302983283996582031250000000
0 10:29:31.595 Test_Double_For EURCHF,H4: i = 2.3999999999999999999999119182158029987476766109466552734375000000000
0 10:29:31595 Test_Double_For EURCHF,H4: i = 2.6000000000000088817841970012523233890533447265625000000000
0 10:29:31595 Test_Double_For EURCHF,H4: MaxPass: 10 count: 9
0 10:29:31.595 Test_Double_For EURCHF,H4: Last i = 2.8000000000000002664535259100375697016716003417968750000000
here it is, read Nikolay's post, he described the work with double in great detail and with great qualityhttps://www.mql5.com/ru/forum/1111/page2623#comment_14473837
If you cannot digest the material from the first time, try to replace Print() with printf() with output of double at least to 15-th digithttps://www.mql5.com/ru/forum/1111/page2623#comment_14474138.
Maybe then you will see why this is so.
Thanks, I understand why it happens, that's why I tried to normalize it. It did not 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?
So the question remains, "double" can be used in the loop
can
and get always the correct number of iterations?
the value of double is always correct, but it does not correspond to the positional decimal system you would like to see or get
Thanks, I understand why this happens, that's why I tried to normalise. It did not work for me. Alexey Viktorov option did not fix it either, the values remain non-normalized
Any manipulation with the double conversion will always have limitations, I doubt that this problem can be solved in the way as in your examples
Make a reliable solution: use int in the loop and the formula to calculate the result value of double and do not use addition of double as a result when iterating in the loop - once again look at my example in the dialogue with Nikolaev