The following lists alphabetically built-in PTL functions available for basic mathematic computations.
These functions are placed in Math package.
List of available functions:
MathAbs
Returns the absolute value of the number specified.
Syntax
Parameters
Example
double f1;
double f2;
f1 = MathAbs(-5.5); // f1 <- 5.5
f2 = MathAbs(8.2); // f2 <- 8.2
MathArccos
Returns the radian value of the angle whose cosine is specified.
Syntax
Parameters
Example
double f1;
double f2;
f1 = MathArccos(-0.2); // f1 <- 1.77215424758523
f2 = MathArccos(0.9872); // f2 <- 0.160171160067318
MathArcsin
Returns the radian value of the angle whose sine is specified.
Syntax
double MathArcsin(int value) |
Parameters
MathArctan
Returns the radian value of the angle whose tangent is specified.
Syntax
Parameters
Example
double f1;
double f2;
f1 = MathArctan(-0.2); // f1 <- -0.197395559849881
f2 = MathArctan(0.9872); // f2 <- 0.778957028643464
MathCeil
Returns the smallest whole number greater than or equal to the value specified (rounds up).
Syntax
Parameters
Example
double f1;
double f2;
f1 = MathCeil(-1.2); // f1 <- -1.0
f2 = MathCeil(5.12); // f2 <- 5.0
MathCos
Returns the cosine of the angle (in radians) specified.
Syntax
Parameters
Example
double f1;
double f2;
f1 = MathCos(456.0); // f1 <- -0.891991243357829
f2 = MathCos(-0.2); // f2 <- 0.890066577841242
MathCosh
Returns the hyperbolic cosine of the angle (in radians) specified.
Syntax
Parameters
Example
double f1;
double f2;
f1 = MathCosh(4.0); // f1 <- 27.3082328360165
f2 = MathCosh(-0.2); // f2 <- -1.02006675561908
MathCotan
Returns the cotangent of the angle (in radians) specified.
Syntax
Parameters
Example
double f1;
double f2;
f1 = MathCotan(4.0); // f1 <- 0.863691154450617
f2 = MathCotan(-0.2); // f2 <- -4.93315487558689
MathExp
Returns the exponent of the number specified.
Syntax
Parameters
Example
double f1;
double f2;
f1 = MathExp(4.0); // f1 <- 54.5981500331442
f2 = MathExp(-0.2); // f2 <- 0.818730753077982
MathFract
Returns the fractional part of a specified value
Syntax
Parameters
Example
double f1;
double f2;
f1 = MathFract(4.8); // f1 <- 0.8
f2 = MathFract(-0.2); // f2 <- 0.2
MathInt
Calculate the integer part of a specified number.
Syntax
Parameters
MathLn
Returns the natural logarithm (base e) of the number specified or NaN.
Syntax
Parameters
Example
double f1;
double f2;
f1 = MathLn(4.8); // f1 <- 1.56861591791385
f2 = MathLn(0.2); // f2 <- -1.6094379124341
MathLg
Returns the common logarithm (base 10) of the number specified or NaN.
Syntax
Parameters
Example
double f1;
double f2;
f1 = MathLg(4.8); // f1 <- 0.681241237375587
f2 = MathLg(0.2); // f2 <- -0.698970004336019
MathLog
Returns the logarithm of the specified number to the specified base or NaN.
Syntax
double MathLog( double value, int base) |
Parameters
MathMax
Returns the larger of the two numbers specified.
Syntax
double MathMax( double value1, double value2) double MathMax( int value1, int value2) |
Parameters
Example
double f1;
double f2;
f1 = MathMax(4.8, 1.2); // f1 <- 4.8
f2 = MathMax(25.1, 0.5); // f2 <- 25.1
MathMin
Returns the smaller of the two numbers specified.
Syntax
double MathMin( double value1, double value2) double MathMin( double value1, int value2) |
Parameters
Example
double f1;
double f2;
f1 = MathMin(2.2, 5.0); // f1 <- 2.2
f2 = MathMin(0.2, -1.5); // f2 <- -1.5
MathMod
Returns the remainder of division. A result value such that (a/b)*b+(a%b) is equal to a.
Syntax
double MathMod( double value1, int value2) |
Parameters
MathNormalize
Returns the number closest to the specified number, divisible by the specified sampling interval. For example, normalizing the value of 1.3 at the sampling interval of 0.25 would return 1.25.
Syntax
double MathNormalize( double value, double interval) double MathNormalize( double value, int interval) |
Parameters
Remarks
MathNormalize is usually used to sample continuous price data at specified intervals.
Example
double f1;
double f2;
f1 = MathNormalize(15.68, 1.25); // f1 <- 16.25
f2 = MathNormalize(90.8, 2.0); // f2 <- 90.0
MathPow
Returns the result of the specified number raised to the specified power.
Syntax
double MathPow( double value, int power) |
Parameters
MathRand
Returns a random number less than the specified maximum or random number between the two specified numbers.
Syntax
| double MathRand( double value1, int value2) |
Parameters
Example
double f1;
f1 = MathRand(3200.2);
MathRound
Rounds a decimal to nearest number
Syntax
Parameters
Example
int f1;
f1 = MathRound(10.12584, 3); // 10
MathSign
Returns the sign of the value specified (signum function).

Syntax
Parameters
Example
double f1;
f1 = MathSign(12); // 1
MathSin
Returns the sine of the angle (in radians) specified.
Syntax
Parameters
MathSinh
Returns the hyperbolic sine of the angle (in radians) specified.
Syntax
Parameters
Example
double f1;
double f2;
f1 = MathSinh(5.8); // f1 <- 165.148266177452
f2 = MathSinh(0); // f2 <- 0
MathSqr
Returns the squared value specified.
Syntax
Parameters
Example
double f1;
double f2;
f1 = MathSqr(4); // f1 <- 16
f2 = MathSqr(-9); // f2 <- 81
MathSqrt
Returns the square root of the value specified.
Syntax
Parameters
Example
double f1;
double f2;
f1 = MathSqrt(4); // f1 <- 2
f2 = MathSqrt(15.2); // f2 <- 3.89871773792359
MathTan
Returns the tangent of the angle (in radians) specified.
Syntax
Parameters
Example
double f1;
double f2;
f1 = MathTan(-5.5); // f1 <- 0.995584052213885
f2 = MathTan(8.2); // f2 <- -2.77374929538342
MathTanh
Returns the hyperbolic tangent of the angle (in radians) specified.
Syntax
Parameters
Example
double f1;
double f2;
f1 = MathTanh(-5.5); // f1 <- -0.999966597156304
f2 = MathTanh(8.2); // f2 <- 0.999999849130844