Custom Criteria Coding issues - page 4

Nicholas C Weber
263
Nicholas C Weber  
R4tna C #:
The key recommendation is to use Normalize at the time of comparison.

I think I missed that your doing it more frequently as Dominik has pointed out 

Anyway let's resume when time allows

MQL5 marketplace didn't like me posting normalize(double, #) at all. it wouldn't validate the EA. Once I removed normalize, it validated. It works either way inside MT5, though, soooo, idk what's going on with the MQL5 validator.

Is it possible that having normalized a double elsewhere in the code with a different decimal would throw it off? What would cause that, for future prevention?

Dominik Christian Egert
2606
Nicholas C Weber #:

MQL5 marketplace didn't like me posting normalize(double, #) at all. it wouldn't validate the EA. Once I removed normalize, it validated. It works either way inside MT5, though, soooo, idk what's going on with the MQL5 validator.

Is it possible that having normalized a double elsewhere in the code with a different decimal would throw it off? What would cause that, for future prevention?


I guess it is because, in case you haven't removed them, these calls are complete non sense and will not make any change to the variable, as you do not assign the result to any storage, but throw it into the void.

NormalizeDouble(param, 2);

NormalizeDouble() returns a value, where is it stored?


Nicholas C Weber
263
Nicholas C Weber  
Dominik Christian Egert #:

I guess it is because, in case you haven't removed them, these calls are complete non sense and will not make any change to the variable, as you do not assign the result to any storage, but throw it into the void.


NormalizeDouble() returns a value, where is it stored?


Oh, I see. That clicked finally. terminology.. So it just is to be used in an instant, whatever equation it's in, not as a return for a double or anything, if I understand you correctly.

Dominik Christian Egert
2606
Nicholas C Weber #:

Oh, I see. That clicked finally. terminology.. So it just is to be used in an instant, whatever equation it's in, not as a return for a double or anything, if I understand you correctly.

You need to think about what you are trying to achieve.

As said, you are overdoing your Normalize calls.

Whenever you store a double for later use, you can normalize it, no need to do it every time you use the value. Only when changing it, afterwards, you need to normalize them, if you want to do reliable "==" equal comparisons. This applies also to ">=" and "<=".

But not for every access, reading the value.

Maybe you can get familiar with how programs work by using the debugger and going through every step and see how your values change.