Download MetaTrader 5
To add comments, please log in or register
Register at MQL5.community and leave your comments!
Георги Дичев
41
Георги Дичев 2015.09.15 17:59 

Hello, traders!

This is my first forum post on this forum but I really need this one. I'm having pretty peculiar trouble with the function MathAbs int MQL4. It returns a NEGATIVE number. I have two edits of the particular line and it still returns negative. Here it is.

The original one:

LotSize = NormalizeDouble(OrderLots()*MathAbs((OrderTakeProfit()-OrderStopLoss())/(ATR/Point)),2);

And after getting negative by this one I used MathAbs one more time:

LotSize = MathAbs(NormalizeDouble(OrderLots()*MathAbs((OrderTakeProfit()-OrderStopLoss())/(ATR/Point)),2));

The later should in theory make an absolute of the resulting number (although it SHOULD be absolute too). To my rising anger the result is still negative.

Any help will be much appreciated, thanks in advance! 

whroeder1
13977
whroeder1 2015.09.15 18:05  
  1. The result is not negative. Your problem is elsewhere. Print your variables.
  2. Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong
/
To add comments, please log in or register