HELP! The weirdest BUG EVER!

 

ok, it's so weird!

I'm building an intra-day trading forex strategy. It's calculating the difference between the day high and the day low rates and trades on if this difference it 60-80 pips.

In order to check if we're between 60 to 80 pips, I use this code line:

if (len>=0.0060 && len<=0.0080)......... bla bla bla

Of course, "len" is calculated by: day high rate minus day low rate.... and every new day I'm resetting these parameters and put "0" in "len"...

for some reason, it does not work... for some reason, "len" is getting bigger and bigger every day.

Now, you would probably say I have some problem with my code. Well, explain this please: when I'm coding it like this:

if (len>=0.0060)... bla bla bla

EVERYTHING WORKS JUST FINE!

When I'm not using "&&" the "len" parameter is resetting and the code is good. When I add the "&& len<=0.0080" - it gets massed up!

Any ideas?

 
There are no mind readers here. Do you really expect help when your problem is the calculation of "len" and you don't post the code calculating len?
 
adibi83:

ok, it's so weird!

I'm building an intra-day trading forex strategy. It's calculating the difference between the day high and the day low rates and trades on if this difference it 60-80 pips.

In order to check if we're between 60 to 80 pips, I use this code line:

if (len>=0.0060 && len<=0.0080)......... bla bla bla

Of course, "len" is calculated by: day high rate minus day low rate.... and every new day I'm resetting these parameters and put "0" in "len"...

for some reason, it does not work... for some reason, "len" is getting bigger and bigger every day.

Now, you would probably say I have some problem with my code. Well, explain this please: when I'm coding it like this:

if (len>=0.0060)... bla bla bla

EVERYTHING WORKS JUST FINE!

When I'm not using "&&" the "len" parameter is resetting and the code is good. When I add the "&& len<=0.0080" - it gets massed up!

Any ideas?

If len is getting bigger and bigger then it is likely that it will always be greater than 0.0060 and quite quickly will not be less than 0.0080

You need to show your code where you are resetting the value of len . . . you might want to use a better variable name than len, is it short for Lennard ?

 

try this way:

if ((len>=0.0060) && (len<=0.0080))

 
szgy74:

try this way:

if ((len>=0.0060) && (len<=0.0080))


TX but I tried it and it didn't work s well....
 
szgy74: try this way: if ((len>=0.0060) && (len<=0.0080))
Read the Precedence rules - MQL4 Documentation before posting. && is lower then comparisons: ((len>=0.0060) && (len<=0.0080)) is the same as ( len>=0.0060 && len<=0.0080 )
 
WHRoeder:
Read the Precedence rules - MQL4 Documentation before posting. && is lower then comparisons: ((len>=0.0060) && (len<=0.0080)) is the same as ( len>=0.0060 && len<=0.0080 )


There are no bugs mentioned in the doc so what is this forum about? :-)

I don't remember right now where I have read a test on interpreting failures of conditions without ( ) usage everywhere. I mean separating different conditions with ( ).

I don't know whether it has been corrected since then. Surely less problem when using them.

 

The bug is in his unposted code. This forum is about mq4. If you mean this thread. The OP has a problem with is calculation of his variable len. It keeps increasing, so, of course, after a while, the len <= 0.0080 is always false.