Math reference
The 23 functions and 3 values of math: signature, effects, phase, cost and tested examples.
Arithmetic and elementary functions. The functions that need a transcendental calculation (math.log, math.exp, math.pow and the trigonometric functions) use the deterministic math kernel, so they give the same numbers on every machine.
Functions#
math.abs#
math.abs(value)
The absolute value.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: a number.
- Examples: User functions, Lazy operators.
math.acos#
math.acos([value])
A trigonometric function, in radians.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: a number.
math.asin#
math.asin([value])
A trigonometric function, in radians.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: a number.
math.atan#
math.atan([value])
A trigonometric function, in radians.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: a number.
math.avg#
math.avg(...values)
The mean of its arguments.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: a number.
math.ceil#
math.ceil(value)
The smallest whole number that is not less than the value.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: a number.
math.cos#
math.cos(value)
A trigonometric function, in radians.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: a number.
math.exp#
math.exp(value)
e raised to the value.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: a number.
math.floor#
math.floor(value)
The largest whole number that is not more than the value.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: a number.
math.log#
math.log(value)
The natural or base-10 logarithm.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: a number.
math.log10#
math.log10(value)
The natural or base-10 logarithm.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: a number.
math.max#
math.max(...values)
The smallest or largest of its arguments.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: a number.
- Examples: RSI written out, Session highs, Trade tally.
math.min#
math.min(...values)
The smallest or largest of its arguments.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: a number.
- Examples: RSI written out.
math.pow#
math.pow(base, exponent)
base raised to exponent.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: a number.
math.random#
math.random([min], [max], [seed])
A pseudo-random number from min to max. The same seed and the same call site give the same numbers on every run and every machine.
- Effects: keeps a state for each place it is written (a call site) and advances it when execution reaches the call.
- Phase: every bar.
- Cost: one state per call site.
- Returns: a number.
- Examples: Seeded random numbers.
math.rem#
math.rem(a, b)
The remainder of a divided by b, with the sign of a.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: a number.
math.round#
math.round(value, [precision])
Rounds to the nearest whole number, or to precision decimals.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: a number.
math.sign#
math.sign(value)
-1, 0 or 1 by the sign of the number.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: a number.
- Examples: On-balance volume.
math.sin#
math.sin(value)
A trigonometric function, in radians.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: a number.
math.sqrt#
math.sqrt(value)
The square root.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: a number.
math.tan#
math.tan(value)
A trigonometric function, in radians.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: a number.
math.to_degrees#
math.to_degrees([value])
Converts between radians and degrees.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: a number.
math.to_radians#
math.to_radians([value])
Converts between radians and degrees.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: a number.
Values#
math.emath.phimath.pi