I try to write script with analyses distribution of last two digits of Highs/Lows.
Analysing with Excel I noticed that daily highs/lows are save some values more often than others so I decided to make script for this job.
Script uses array[100] from 0 to 99 (last 2 digits) and MathFloor to compare highs/lows with array, calculates number of every digit and writes values to file.
However only if last two digits are 00, 25,50 and 75 are calculated properly. Other values are not calculated.
Maybe I use MathFloor command inproperly ?
I suspect your problem has to do with float rounding errors. I suggest you attempt comparing double numbers using CompareDoubles() function that comes with stdlib.mq4 (for example in the line: if ( Last2digits == 5)). Please c more info here -> Articles -> Features -> Working with Doubles in MQL4 .
I suspect your problem has to do with float rounding errors. I suggest you attempt comparing double numbers using CompareDoubles() function that comes with stdlib.mq4 (for example in the line: if ( Last2digits == 5)). Please c more info here -> Articles -> Features -> Working with Doubles in MQL4 .
Hi Gordon,
Thank for advice. I read the article, and command DoubletoStr solved the problem :)
Edward
int HighLowCount [100] = {0,0,0,0 Last2digits = (High[i] - MathFloor(High[i]))*100
All variable default to zero (except strings) so the {0,0,0 ... is unnessariy
Last2digits = {1.5234 - floor(1.5234) }*100 = {1.5234-1}*100 = 52.34
you probably want
int Last2digits = High[i]/Point % 100; HighLowCount[Last2digits]++;
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I try to write script with analyses distribution of last two digits of Highs/Lows.
Analysing with Excel I noticed that daily highs/lows are save some values more often than others so I decided to make script for this job.
Script uses array[100] from 0 to 99 (last 2 digits) and MathFloor to compare highs/lows with array, calculates number of every digit and writes values to file.
However only if last two digits are 00, 25,50 and 75 are calculated properly. Other values are not calculated.
Maybe I use MathFloor command inproperly ?
Thanks,
Edward