Overbasic – Math functions

My.Math category contains all the mathematical (math) built-in functions available in Overbasic.

Abs #

Returns the absolute value of a number/numeric-expression.

Result type: numeric

Arguments:

  • EXPRESSION: any numeric expression.
Dim a As Numeric = My.Math.Abs(-2) 'Result: 2
Dim b As Numeric = My.Math.Abs(10) 'Result: 10

Atan #

Returns the angle in radians of a number/numeric-expression.

Result type: numeric

Arguments:

  • EXPRESSION: any numeric expression representing a tangent.
Dim a As Numeric = My.Math.Atan(1) 'Result: 0.78539816339745

Cdeg #

Converts a number/numeric-expression from radians to degrees.

Result type: numeric

Arguments:

  • EXPRESSION: any numeric expression.
Dim a As Numeric = My.Math.Cdeg(0.78539816339745) 'Result: 45

Cnum #

Returns the numeric value of a string.

Result type: numeric

Arguments:

  • EXPRESSION: any string.
Dim a As Numeric = My.Math.Cnum("2") 'Result: 2

Cos #

Returns the cosine of an angle.

Result type: numeric

Arguments:

  • EXPRESSION: any numeric expression representing an angle in radians.
Dim a As Numeric = My.Math.Cos(3.14159265358979) 'Result: -1

Crad #

Converts a number/numeric-expression from degrees to radians.

Result type: numeric

Arguments:

  • EXPRESSION: any numeric expression representing an angle in degrees.
Dim a As Numeric = My.Math.Crad(45) 'Result: 0.78539816339745

Dec #

Returns the decimal part of a number/numeric-expression.

Result type: numeric

Arguments:

  • EXPRESSION: any numeric expression.
Dim a As Numeric = My.Math.Dec(2.5) 'Result: 0.5

Exp #

Returns e (a mathematical constant whose value is approximately 2.71828) raised to the specified power. It is the inverse of the Log function: Eg. Log(10) = 2.30258, Exp(2.30258) = 10

Result type: numeric

Arguments:

  • EXPRESSION: any numeric expression.
Dim a As Numeric = My.Math.Exp(2) 'Result: 7.38905609893065

Fix #

Returns the integer part of a number/numeric-expression. If number is negative, returns the first negative integer greater than or equal to.

Result type: numeric

Arguments:

  • EXPRESSION: any numeric expression.
Dim a As Numeric = My.Math.Fix(2.5) 'Result: 2
Dim b As Numeric = My.Math.Fix(-2.7) 'Result: -2

Int #

Returns the integer part of a number/numeric-expression. If number is negative, returns the first negative integer lower than or equal.

Result type: numeric

Arguments:

  • EXPRESSION: any numeric expression.
Dim a As Numeric = My.Math.Int(2.5) 'Result: 2
Dim b As Numeric = My.Math.Int(-2.7) 'Result: -3

Log #

Calculates the natural logarithm (or of the specified base) of a number/numeric-expression.

Result type: numeric

Arguments:

  • EXPRESSION: any numeric expression.
  • BASE: (optional) is the base of the logarithm. If not specified, it is the base of the natural logarithm (2.71828).
Dim a As Numeric = My.Math.Log(10) 'Result: 2.30258
Dim b As Numeric = My.Math.Log(10, 10) 'Result: 1

Mod #

Returns the remainder after dividing two numbers/numeric-expressions.

Result type: numeric

Arguments:

  • EXPRESSION1: any numeric expression.
  • EXPRESSION2: any numeric expression.
Dim a As Numeric = My.Math.Mod(5, 4) 'Result: 1

Pi #

Returns PI value.

Result type: numeric

Dim a As Numeric = My.Math.Pi 'Result: 3.14159265358979

Rnd #

Returns a random number between 0 and 1.

Result type: numeric

Dim a As Numeric = My.Math.Rnd

Round #

Rounds the decimal part of a number to a specific digit.

Result type: numeric

Arguments:

  • EXPRESSION any numeric expression.
  • DECIMALS: (optional) any numeric expression representing the decimal digit to which to round EXPRESSION. If omitted, EXPRESSION is rounded to the nearest integer.
Dim a As Numeric = My.Math.Round(21.456) 'Result: 21
Dim b As Numeric = My.Math.Round(21.456, 0) 'Result: 21
Dim c As Numeric = My.Math.Round(21.456, 1) 'Result: 21.5
Dim d As Numeric = My.Math.Round(21.456, 2) 'Result: 21.46

Sin #

Returns the sine of an angle.

Result type: numeric

Arguments:

  • EXPRESSION: any numeric expression representing an angle in radians.
Dim a As Numeric = My.Math.Sin(3.14159265358979) 'Result: 0

Sqr #

Returns the square root of a number/numeric-expression.

Result type: numeric

Arguments:

  • EXPRESSION: any numeric expression.
Dim a As Numeric = My.Math.Sqr(4) 'Result: 2

Stdev #

Calculates the standard deviation of a data series considering the last x periods.

Result type: numeric

Arguments:

  • DATA any data function (e.g. Open, High, Low, Close, Volume), indicator, array type variable (or function).
  • PERIODS: number of bars to calculate the standard deviation on.
Dim a As Numeric = My.Math.Stdev(Close, 10)

Sum #

Sum EXPRESSION results of last x periods.

Result type: numeric

Arguments:

  • EXPRESSION any numeric expression.
  • PERIODS: number of bars to calculate Expression on (including current bar).
'Sum Close values of last 10 bars:
Dim a As Numeric = My.Math.Sum(Close, 10)

Tan #

Returns the tangent of an angle.

Result type: numeric

Arguments:

  • EXPRESSION: any numeric expression representing an angle in radians.
Dim a As Numeric = My.Math.Tan(3.14159265358979 / 4) 'Result: 1

Val #

Returns the numeric value of a string.

Result type: numeric

Arguments:

  • EXPRESSION: any string.
Dim a As Numeric = My.Math.Val("2") 'Result: 2