math.sign
The sign of number: -1 for a negative number and 1 for a positive one.
The result is a float, not an int. Every other member that reduces a number to a whole value - math.ceil, math.floor, the one-argument math.round - returns an int, so this one is worth reading twice.
math.sign(const float number) → const floatmath.sign(input float number) → input floatmath.sign(series float number) → series floatmath.sign(simple float number) → simple float| Parameter | Type | Required | Description |
|---|---|---|---|
number | const float | yes | The number to take the sign of. |
Returns const float or input float or series float or simple float — A float in the argument’s form.
indicator("Sign of the body")
plot(math.sign(close - open))See also math.abs · math.acos · math.asin
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.