A quick mathematical problem

Back to topics list To post a new topic, please log in or register
avatar
1
kutalion 2015.09.15 19: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! 

avatar
13000
WHRoeder 2015.09.15 20: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
Back to topics list  

To add comments, please log in or register