Download MetaTrader 5

A quick mathematical problem

To add comments, please log in or register
Георги Дичев
41
Георги Дичев  

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
16099
whroeder1  
  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