Definition: The absolute value of number is number if number >= 0, or -number otherwise.
Syntax:
math.abs(number) β simple int/float
math.abs(number) β series int/float
Returns:
The absolute value of `number`.
Arguments:
Name
Type
Description
number
simple int/float
The number for which to calculate the absolute value.
math.acos
Definition: The acos function returns the arccosine (in radians) of number such that cos(acos(y)) = y for y in range [-1, 1].
Syntax:
math.acos(angle) β simple float
math.acos(angle) β series float
Returns:
The arc cosine of a value; the returned angle isin the range[0, Pi],or na if y is outside of range[-1,1].
Arguments:
Name
Type
Description
angle
simple float
The angle in radians for which to calculate the arccosine.
math.asin
Definition: The asin function returns the arcsine (in radians) of number such that sin(asin(y)) = y for y in range [-1, 1].
Syntax:
Returns:
Arguments:
Name
Type
Description
angle
simple float
The angle in radians for which to calculate the arcsine.
math.atan
Definition: The atan function returns the arctangent (in radians) of number such that tan(atan(y)) = y for any y.
Syntax:
Returns:
Arguments:
Name
Type
Description
angle
simple float
The angle in radians for which to calculate the arctangent.
math.avg
Definition: Calculates the average of all given series (elementwise).
Syntax:
Returns:
Arguments:
Name
Type
Description
number0, number1, ...
series float
The series of numbers to calculate the average of. Multiple series can be provided.
math.ceil
Definition: Returns the smallest integer greater than or equal to the argument.
Syntax:
Returns:
Arguments:
Name
Type
Description
number
series float
The number to ceil.
math.cos
Definition: Returns the trigonometric cosine of an angle.
Syntax:
Returns:
Arguments:
Name
Type
Description
angle
series float
The angle in radians.
math.exp
Definition: Returns the value of Euler's number raised to the power of the given number.
Syntax:
Returns:
Arguments:
Name
Type
Description
number
series float
The number for which to calculate the exponent.
math.floor
Definition: Returns the largest integer less than or equal to the given number.
Syntax:
Returns:
Arguments:
Name
Type
Description
number
series int
The number for which to calculate the floor value.
math.log
Definition: Returns the natural logarithm of any number greater than 0.
Syntax:
Returns:
Arguments:
Name
Type
Description
number
series float
The number for which to calculate the natural logarithm.
math.log10
Definition: Returns the base 10 logarithm of a number.
Syntax:
Returns:
Arguments:
Name
Type
Description
number
series float
The number for which to calculate the base 10 logarithm.
math.max
Definition: Returns the greatest of multiple values.
Syntax:
Returns:
Arguments:
Name
Type
Description
number0, number1, ...
series int/float
The values to compare and find the greatest among them.
math.min
Definition: Returns the smallest of multiple values.
Syntax:
Returns:
Arguments:
Name
Type
Description
number0, number1, ...
series int/float
The values to compare and find the smallest among them.
math.pow
Definition: Mathematical power function.
Syntax:
Returns:
Arguments:
Name
Type
Description
base
series int/float
Specify the base to use.
exponent
series int/float
Specifies the exponent.
math.random
Definition: Returns a pseudo-random value. The function will generate a different sequence of values for each script execution. Using the same value for the optional seed argument will produce a repeatable sequence.
Syntax:
Arguments:
Name
Type
Description
min
series int/float
The lower bound of the range of random values. The value is not included in the range. The default is 0.
max
series int/float
The upper bound of the range of random values. The value is not included in the range. The default is 1.
seed
series int
Optional argument. When the same seed is used, allows successive calls to the function to produce a repeatable set of values.
Returns:
math.round
Definition: Returns the value of number rounded to the nearest integer, with ties rounding up. If the precision parameter is used, returns a float value rounded to that amount of decimal places.
Syntax:
Returns:
Arguments:
Name
Type
Description
number
series int/float
The value to be rounded.
precision
series int
Optional argument. Decimal places to which number will be rounded. When no argument is supplied, rounding is to the nearest integer.
math.sign
Definition: Sign (signum) of number is zero if number is zero, 1.0 if number is greater than zero, -1.0 if number is less than zero.
Syntax:
Returns:
Arguments:
Name
Type
Description
number
series int/float
The number for which to determine the sign.
math.sin
Definition: The sin function returns the trigonometric sine of an angle.
Syntax:
Returns:
Arguments:
Name
Type
Description
angle
series int/float
Angle, in radians.
math.sqrt
Definition: Square root of any number >= 0 is the unique y >= 0 such that y^2 = number.
Syntax:
Returns:
Arguments:
Name
Type
Description
number
series int/float
The number to calculate the square root of. It must be greater than or equal to 0.
math.sum
Definition: The sum function returns the sliding sum of last y values of x.
Syntax:
Arguments:
Name
Type
Description
source
series int/float
Series of values to process.
length
series int
Number of bars (length).
Returns:
math.tan
Definition: The tan function returns the trigonometric tangent of an angle.
Syntax:
Returns:
Arguments:
Name
Type
Description
angle
series int/float
Angle, in radians.
math.todegrees
Definition: Returns an approximately equivalent angle in degrees from an angle measured in radians.
Syntax:
Arguments:
Name
Type
Description
radians
series int/float
Angle in radians.
Returns:
math.toradians
Definition: Returns an approximately equivalent angle in radians from an angle measured in degrees.
math.pow(base, exponent) β simple float
math.pow(base, exponent) β series float
`base` raised to the power of `exponent`. If `base` is a series, it is calculated elementwise.
math.random(min, max, seed) β series float
A random value.
math.round(number) β simple int
math.round(number) β series int
math.round(number, precision) β simple float
math.round(number, precision) β series float
The value of `number` rounded to the nearest integer, or according to precision.
math.sign(number) β simple float
math.sign(number) β series float
The sign of the argument.
math.sin(angle) β simple float
math.sin(angle) β series float
The trigonometric sine of an angle.
math.sqrt(number) β simple float
math.sqrt(number) β series float
The square root of `number`.
math.sum(source, length) β series float
Sum of `source` for `length` bars back.
math.tan(angle) β simple float
math.tan(angle) β series float