Page 1 of 1
Posted: Wed Aug 17, 2011 1:27 am
I posted this on the MT4 board with no response yet.
I am printing the following statement:
Print(Order_Symbol, ",", Order_Quantity, ",",(OrderType() == 1),",", (Order_Quantity == 0));
It returns (symbol, 0, 1, 0)
Any idea how Order_Quantity = 0 and Order_Quantity == 0 could return FALSE in the same statement? Order_Quantity is declared as a double/floating variable.
Posted: Wed Aug 17, 2011 7:39 am
Not an MT4 programmer, this could be balderdash.
1. Blox's programming language has ways to force a PRINT statement to print a floating point variable with lots of digits of precision. Maybe MT4's programming language has a feature like that, too. Perhaps when you print with lots of digits of precision, you may discover that Order_Quantity isn't zero, but rather it's 1.234e-19 .
2. Tradestation EasyLanguage was, once upon a time, notoriously unreliable if you passed an expression
as an argument to a function. Maybe MT4 has got this disease too? Maybe if you performed a couple of assignment statements
- temp1 = 0;
if(OrderType() == 1) then temp1 = 1;
temp2 = 0 ;
if(Order_Quantity != 0.00) then temp2 = 1;
Print( symbol , Order_Quantity, temp1, temp2) ;
and then printed the results of the assignment statements, you could feel cozy that you have bypassed this category of possible bugs.
3. Maybe MT4 has funny rules about comparisons that involve floats. Maybe a comparison (float == integer) ALWAYS fails, and maybe your comparison (Order_Quantity == 0) is considered to be a comparison between a float and an integer. If so you could change it so that even the dumbest compiler would recognize both as floats, perhaps
- Order_Quantity == 0.000
Order_Quantity < 0.000001234
Posted: Wed Aug 17, 2011 7:43 am
In programming language like C++ double == sign mean a comparaison not an assignment
This is why Quantity == 0 return false
Quantity = 0 is an assignment, ie I want Quantity to = to 0
This is something that The VB version in TB handle differently, in both case in TB it mean assignment. I had ask that question at the time in a Blox conference in Boston
Posted: Wed Aug 17, 2011 9:32 am
It was a precision problem. I cant for the life of me figure out where the issue is being introduced, but lopping off some unnecessary decimal places is taking care of it.