Use function from Stdlib.mq4
//+------------------------------------------------------------------+ //| right comparison of 2 doubles | //+------------------------------------------------------------------+ bool CompareDoubles(double number1,double number2) { if(NormalizeDouble(number1-number2,8)==0) return(true); else return(false); }
ThomasB:
MQL4 often has trouble with comparing doubles with ==, I once had that I did this:
double a = b
if(b!=a) Print("Bug");
And it printed Bug!
Anyway - work around it with MathAbs(Bid-SellLevel)<0.0001 or something like that.
MQL4 often has trouble with comparing doubles with ==, I once had that I did this:
double a = b
if(b!=a) Print("Bug");
And it printed Bug!
Anyway - work around it with MathAbs(Bid-SellLevel)<0.0001 or something like that.
This is not only problem of MQL4. in all programming languages you should round your double numbers before comparing. I remember this problem from ages of using turbo pascal upto now.
If you wont to compare the Bid price which is given by the terminal and are a number
from the typ double, with another double number it is often better when you compare
like this : if SellLevel is between High[0] and Low[0] because the Bid price can
always do not reach and jump and than a queries will not match.
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 know that the specific problem is the line "Bid = SellLevel"
I'm sure that it Normalized to the right decimal point. When I removed that simple command- The order goes through. When I add it, the order doesn't get iniated (with no errors).
So I am kind of stuck.
Could someone tell me if "Bid = SellLevel" is correct?
*Note- if you run it in the backtest, you can see the price for "SellLevel, SellStop, and SellLimit". They look compeletly right. I have tried switching Bid with both Point and Ask.
-J