I am writing High/Low analysis script - could you help solve problem ?

 

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

 
edas:

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 .

 
gordon:

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]++;
Reason: