OrderOpenPrice()== LineBuy
Wrong.
" The equality of two real numbers can't be compared. In most cases, two seemingly identical numbers can be unequal because of different values in the 15th decimal place. In order to correctly compare two real numbers, compare the normalized difference of these numbers with zero. "
if (OrderType() == OP_BUY && fabs(OrderOpenPrice()-LineBuy)<0.5*Distance )
would be better.
Documentation on MQL5: Language Basics / Data Types / Real Types (double, float)
- www.mql5.com
Real types (or floating-point types) represent values with a fractional part. In the MQL5 language there are two types for floating point numbers.The method of representation of real numbers in the computer memory is defined by the IEEE 754 standard and is independent of platforms, operating systems or programming languages. Floating-point...
Doubles are rarely equal. Understand the links in:
The == operand. - MQL4 programming forum
The == operand. - MQL4 programming forum
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
Hello,
I'm working on modifications to an EA that uses a grid and reactivates lines when the market moves a set distance away. For testing purposes i'm using a grid size of 10 pips and the same activation distance. In order to prevent constant orders on the same lines i want to limit it to 1 buy and 1 sell on any given line. I just can't seem to get the logic correct. What i'm seeing with the current code is that it is allowing trades when it should not and it is not really preventing anything and i can't seem to wrap my head around what i'm dong wrong.
Here is an excerpt from the Journal tab in the tester as you can see it takes Buy for orders 3 and 5 on the same line :
And here is the buy portion of the code that is giving me the trouble:
As always i appreciate any help that is offered.
Thanks!!!