So, about custom code blocks and absolute values, suppose I want the difference between 2 lines, but just want the absolute value
-
Re: How do I get absolute value of a number?
How do I use the MQL Code Block to display the number I am seeking? For example I want the difference of Two moving averages and I have a value whether positive or negative and then I use the code Block, then what follows the code block? I ultimately want to display the absolute value on my screen but I am not sure how to put it into comment ugly
-
@len-1 Why should you use the custom code block? You can get that distance by using the standard 'formula' block and then visualize the result via variable on the 'comment (ugly)' block.
-
So, should I make boolean if I wanted to choose whether to multiply by -1 if negative and just +1 if positive? I wanted to compare candle stick ma's by comparing their absolute value distances, but I was thinking the custom code block may minimize the amounts of blocks I need to do the same thing
-
@len-1 I'm sure a custom code will always be more efficient, but I'm not a programmer so I cannot help there. You can use a 'check distance' block like this:

By selecting yes, the distance will be absolite and you will never need a +1/-1 factor.
-
As always, youre the best L'Andorra! This should help me with something. I am going to resume soon. Thanks
-
You're welcome.

-
@l-andorrà so then is this absolute distance in pips or ?....
For example, if I have a moving average that is at 86.795 and another at 8.830, is the distance .035 or is it 3.5 pips? or how will that absolute distance be registered? -
The absolute distance will be 77.965 pips no matter which one is above the other.