math.abs

The absolute value of number: its magnitude, with the sign removed.

math.abs(const float number) → const float
math.abs(const int number) → const int
math.abs(input float number) → input float
math.abs(input int number) → input int
math.abs(series float number) → series float
math.abs(series int number) → series int
math.abs(simple float number) → simple float
math.abs(simple int number) → simple int
ParameterTypeRequiredDescription
numberconst floatyesThe number to take the magnitude of. An int or a float is accepted.

Returns const float or const int or input float or input int or series float or series int or simple float or simple int — The magnitude of number. An int argument gives an int and a float argument gives a float, in the argument’s own form.

indicator("Body size")
plot(math.abs(close - open))

See also math.acos · math.asin · math.atan

Part of the function index.

Ready to put this into practice?
Try GoCharting Premium
Unlock advanced orderflow, market profile, options desk, and real-time data — everything you just read about, live in your charts.
Upgrade