Skip to content

math ​

Deterministic math helpers. math.random() is seeded per run, so a backtest repeats exactly.

NameDescription
math.abs()Absolute value.
math.max()Largest of the arguments.
math.min()Smallest of the arguments.
math.floor()Rounds down to a whole number.
math.ceil()Rounds up to a whole number.
math.round()Rounds to digits decimals (default 0).
math.sqrt()Square root.
math.pow()x to the power y.
math.log()Natural logarithm.
math.exp()e to the power x.
math.random()seeded; seed is part of the run config

math.abs() ​

ts
math.abs(x: number): number

Absolute value.

math.max() ​

ts
math.max(...xs: number[]): number

Largest of the arguments.

math.min() ​

ts
math.min(...xs: number[]): number

Smallest of the arguments.

math.floor() ​

ts
math.floor(x: number): number

Rounds down to a whole number.

math.ceil() ​

ts
math.ceil(x: number): number

Rounds up to a whole number.

math.round() ​

ts
math.round(x: number, digits?: number): number

Rounds to digits decimals (default 0).

math.sqrt() ​

ts
math.sqrt(x: number): number

Square root.

math.pow() ​

ts
math.pow(x: number, y: number): number

x to the power y.

math.log() ​

ts
math.log(x: number): number

Natural logarithm.

math.exp() ​

ts
math.exp(x: number): number

e to the power x.

math.random() ​

ts
math.random(): number

seeded; seed is part of the run config

AlphaScript language v0.1 · runtime 0.2.0