Operators - Arithmetic, Relational, Logical

Operators - Arithmetic, Relational, Logical

Arithmetic Description Example
+ Addition HI + LO + CL
- Subtraction MA - CL
* Multiplication (CL * 2 + MA * 3) / 5
/ Division (HI + LO + CL) / 3
% Remainder operator. X % Y results in the remainder of X / Y. For instance, 10%3 = 1. ((CL*100)% 100) / 100
^ Power CL ^ 6
ABS(exp) Absolute Value ABS(CL)
ACOS(exp) Arc Cosine ACOS(exp)
ASIN(exp) Arc Sine ASIN(exp)
ATAN Arc Tangent ATAN(exp)
AVG(exp, n) Average of expression over last n periods. AVG(HI, 12)
COS(exp) Cosine COS(exp)
HCOS(exp) Hyperbolic Cosine HCOS(exp)
HSIN(exp) Hyperbolic Sine HSIN(exp)
HTAN(exp) Hyperbolic Tangent HTAN(exp)
IF(expA) THEN(expB) ELSE(expC) Conditional IF-THEN-ELSE statement. If expA is TRUE, then expB is executed, else expC is executed. IF(CL > MA) THEN (SET(V#1, CL)) ELSE (SET(V#1, MA))
INT(exp) Integer operator. Truncates the expression to a whole number. INT(MA)
INT(29.97) = 29
LOG(exp) Exponential Logarithm (base e) of expression. LOG(CL)
LOGT(exp) Base 10 logarithm of expression value LOGT(CL)
MAX(exp, n) Maximum value of expression over last n periods. MAX(HI, 20)
MIN(exp, n) Minimum value of expression over last n periods. MIN(LO, 30)
PNZ(exp) Returns +1, -1, or 0 corresponding to whether the expression is positive, negative, or zero. PNZ(MACD)
RAND(n, m) Random whole number generator. Generates a random whole number between n and m. RAND(0, 100) / 100
ROU(exp, n) Rounding operator. Rounds the expression off to the nearest multiple of n. ROU(CL, 0.1)
ROU(12.51, 1) = 13
SET(property, exp) Sets the value of property to expression. Property can be any V# variable, the highlight color, etc. SET(V#1, CL - OP)
SHOW(exp) Show the value of expression. This is used for reporting purposes in backtests. SHOW(FASTD)
SIN(exp) Sine SIN(exp)
SMAX(expA, expB) Scalar Maximum. Result is the maximum of the two expressions. SMAX(CL, OP)
SMIN(expA, expB) Scalar Minimum. Result is the minimum of the two expressions. SMIN(CL, OP)
SQRT(exp) Square root of expression. SQRT(CL)
STD(exp, n) Standard Deviation of expression over last n periods. STD(CL, 13)
STDN(exp, n) Standard Deviation of expression over last n periods using n - 1 as divisor STDN(CL, 13)
SUM(exp, n) Sum of expression over last n periods SUM(VO, 20) / 20
TAN(exp) Tangent TAN(exp)

Relational Description Example
< less than HI > MA
<= less than or equal to OP <= CL
= equal to MA = MA1
!= not equal to HI != HI2
> greater than LO > LO3
>= greater than or equal to MA3 >= HI
? conditional expression CL > OP? HI: LO

Logical Description Example
AND Both operands must be true in order for the result to be true. (HI > MA) AND (CL > OP)
OR If either operand is true, or if both are true, then the result is true (HI > MA) AND (CL > OP)
NOT
!
The NOT operator reverses the value of the expression that follows. NOT X is TRUE only if X is FALSE. NOT (MA > OP)
!(MA > OP)