Does anyone know whether there is a function available in MQL4 that converts negative numbers into positive?
I want to measure the length of a candle's body in pips and to do this, I subtract the open from the close. So for bullish candles where the close is higher, the length is a positive number but for bearish candles where the close is lower than the open, the length is a negative number. So I need my function to work for both instances but to result in a positive number.
I could set up an If/ELSE function to determine whether the close is higher or lower than the open, which would then direct it to the appropriate method of subtraction but I was hoping that there was a function already available just to drop the negative symbol from the result.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hi all.
Does anyone know whether there is a function available in MQL4 that converts negative numbers into positive?
I want to measure the length of a candle's body in pips and to do this, I subtract the open from the close. So for bullish candles where the close is higher, the length is a positive number but for bearish candles where the close is lower than the open, the length is a negative number. So I need my function to work for both instances but to result in a positive number.
I could set up an If/ELSE function to determine whether the close is higher or lower than the open, which would then direct it to the appropriate method of subtraction but I was hoping that there was a function already available just to drop the negative symbol from the result.
Mark