The code is pasted below, kindly assist and thanks in advance for your assistance:
What I noticed is a line having "Balance == Equity". Be careful in doing this. Both Balance and Equity are of type double. These may have a rounding error. Due to this it could be for example be that Balance = 100.23 and Equity is 100.2300001. In that case are they not equal and your code will not act on that.
If you want to compare two parameters of type double is it better to define a certain limit of how much they are allowed to be different. For example: if(MathAbs(Balance-Equity) < 0.01*Balance). This allows a difference of up to 1% of the Balance value.What I noticed is a line having "Balance == Equity".
I can't believe people actually do this. Whenever your open position is break-even your Balance == Equity. Never-ever-ever-ever use this code, OP!
The == operand. - MQL4 programming forum
What I noticed is a line having "Balance == Equity". Be careful in doing this. Both Balance and Equity are of type double. These may have a rounding error. Due to this it could be for example be that Balance = 100.23 and Equity is 100.2300001. In that case are they not equal and your code will not act on that.
If you want to compare two parameters of type double is it better to define a certain limit of how much they are allowed to be different. For example: if(MathAbs(Balance-Equity) < 0.01*Balance). This allows a difference of up to 1% of the Balance value.I really appreciate your time and effort at giving more insight and enlightenment on spotted error in my code, thanks so much
Doubles are rarely equal. Understand the links in:
The == operand. - MQL4 programming forum
Thanks for educating me.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
The code is pasted below, kindly assist and thanks in advance for your assistance: