-
Re: Having Absolut Math inserted into Adjust field
I have a number of variables tracking + and - deflections of parity. Can I use = MathAbs($) in the adjust as I assign variables to other variables ?
Example Max Bullish 1 (with = MathAbs($) in adjust) = Max Bullish 2 in the absolute state? Or does it need to be somewhere in it's own block?
I'm trying to replace it's own block with an inversion via x (-1) block.
-
This is one for programmers. Maybe jstap or roar can provide some help.
-
You can use this in text (code input), MathAbs(variable name), there are other ways, test and if not working add a shared link to look at.
-
I have a number of variables tracking + and - deflections of parity. Can I use = MathAbs($) in the adjust as I assign variables to other variables ?
Example Max Bullish 1 (with = MathAbs($) in adjust) = Max Bullish 2 in the absolute state? Or does it need to be somewhere in it's own block?
I'm trying to replace it's own block with an inversion via x (-1) block.Hello,
Great question! Yes, you can use Math.Abs($) (assuming $ represents your variable) directly in the adjustment as you assign variables to others. This will effectively give you the absolute value of the variable, which you can then assign to another variable, ensuring that you are working with positive numbers regardless of the original variable's sign.
For your example, using Math.Abs() to define "Max Bullish 1" and then assigning it to "Max Bullish 2" will indeed result in both variables representing the absolute state of your initial value. This method is both efficient and keeps your code clean.
Regarding your query on replacing its own block with an inversion via a multiplication by -1 block, this is also a viable approach. If you're looking to invert the sign of a value, multiplying by -1 is straightforward. However, if your goal is to ensure the value is always positive, Math.Abs() is the more appropriate choice as it directly converts any number to its absolute value, negating the need for conditional checks or additional blocks to handle negative values.
In summary, for absolute values, directly using Math.Abs() in your assignments is perfectly fine and encouraged for clarity and efficiency. If you're inverting the sign, multiplying by -1 is correct, but for ensuring positivity, stick with Math.Abs().
I hope this clarifies your queries. If you have further questions or need examples, feel free to ask!
-
Thank you! I decided to use another method that will make the bigger picture more efficient.