MyBuffer[bar]= (2.0 / Periods);
Change the 2 to 2.0, otherwise it returns an integer.
In future, please just paste your code using the SRC button, instead of a link. I have done it for you this time.
Change the 2 to 2.0, otherwise it returns an integer.
In future, please just paste your code using the SRC button, instead of a link. I have done it for you this time.
-
Play videoPlease edit your post.
For large amounts of code, attach it.
- On MT4 v434, division quotient don't give floating point values(Bug??) - MQL4 forum
Hello,
while we are discussing floats, i may add somes points, regarding floating point arithmetic in MQL. If someone ever tries to declare a float with a fractional part which is not present in binary, such as 0.6, 1.8, will get a compiler warning "truncation of a constant value". After some searching, we can see that this happens in languages where floats are represented as doubles internally. So, if your number is not x.5,x.25,x.125,() the double will most likely have some trailing numbers, in the end (which are going to be truncated for the number to be represented in float); for example, 0.6 could be 0.5999999999999, or 0.600000000000001 or whatever ( :) ).
p.s. Interestingly enough, if you declare a float with more than 5 digits in fractional part, but that number is in binary "format", like 0.00390625, compiler is not going to complain about any truncation
p.s. 2 Lesson is , there should be not any benefit when using floats in MQL , instead of doubles , quite the contrary probably
p.s. 3 If you would like to use floats for some reason , you can put a "f" after the number e.g. float a=0.6f (but we do not have to, for e.g. float a=0.5)
best regards
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
i use (on line 32) :
2/1 (or 2/2 )
it works well, otherwise, if i put:
2/3 (or 2/4 or etc...)
plot always gets ZERO?
why????????????????