Rosh:
You have to check difference between two double values.
Not
But must be
Really?
I read in the documentation about needing to do subtraction to test equality between two doubles. To test a == b we must do:
if ( NormalizeDouble( a - b, 8 ) == 0 )
which is what CompareDoubles does. But even just to do a simple greater than or less than comparison we have to do the subtraction as well? Is that documented somewhere?

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I've got a strange problem I've picked up today running the strategy tester on an EA.
Take the following code from the start() function...
double RealOpenPrice = NormalizeDouble( OOP - PipBuffer, Digits );
if ( Bid < RealOpenPrice ) {
// Open order here
...
My problem is that RealOpenPrice = 1.5632 and Bid = 1.5632 but the order is still opened. I've done all kinds of debug printing out the values of both using DoubleToStr with 8 decimal places and they appear to be equal. DoubleToStr comes back with "1.56320000" for both numbers. If I call:
CompareDoubles( Bid, RealOpenPrice );
it returns TRUE meaning the two values are equal.
The only way the code works properly is if I normalize Bid before doing the test, for instance:
double Bidn = NormalizeDouble( Bid, Digits );
double RealOpenPrice = NormalizeDouble( OOP - PipBuffer, Digits );
if ( Bidn < RealOpenPrice ) {
// open the order, etc...
Then the code works as it should and the order is not opened. There are other times when the Bid price is the same as RealOpenPrice and I don't see this problem so it doesn't happen every time they are equal.
Aren't Bid/Ask supposed to be already normalized? If so, then is this some sort of bug? Do I need to workaround this anywhere I use the Bid/Ask values?
There's no error generated when the order is placed even though I use Bid as the open price.
MT4 Build 220