- MetaTrader can't do simple math?
- Conditional Statement failure... [At wits end] if ( 1.4225 > 1.4225) is NOT TRUE!!!!!!
- Can price != price ?
Well, im sure you can google it and get some answers..
But you have unusual question about where would you use it? Most people ask the other way around..
From what I understand, CompareDoubles() compares two double values and returns bool true or false. But im just beginner so..
That is where I found out there was a CompareDoubles() function. But what does it do? it is a bool. When does it return true? When both values are the same? I am currently using NormalizeDouble before comparing two doubles. Would it be more effective to use CompareDoubles?
yes.
bool CompareDoubles(double number1,double number2)
{
if(NormalizeDouble(number1-number2,8)==0) return(true);
else return(false);
}
What does CompareDoubles() do and when would one use it? Where is the documentaion for this function?
Using functions like CompareDouble is good habit. It is easy to incorrectly compare values in the code if they are double type. Is 1.00000000001=0.99999999999?
This function will tell you easily if two doubles are equal within 8 digits (true) or not (false).
If you do that without normalization result is unpredictible.
That is where I found out there was a CompareDoubles() function. But what does it do? it is a bool. When does it return true? When both values are the same? I am currently using NormalizeDouble before comparing two doubles. Would it be more effective to use CompareDoubles?
bool CompareDoubles(double number1,double number2) { if(NormalizeDouble(number1-number2,8)==0) return(true); else return(false); }
CB
![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