EasyLanguage Reserved Words & Functions

About Functions

A function call is an EasyLanguage word (appearing in purple) that returns a value (or multiple values) after evaluating underlying EasyLanguage statements within the function.  The function's statements can be used to calculate a mathematical formula or perform any other EasyLanguage action.

Common Usage

A function is assigned to a variable in an assignment statement or included in an expression. Unless otherwise identified, most functions are simple functions.

For example, in the following, the function calculates the average closing price over 10 bars and assigns the returned value to a pre-declared variable:

Value1 = Average(Close, 10);

Series Function

A series function automatically stores its own previous values and executes on every bar (even if used within a conditional statement).  For more information, refer to series function.

Multiple Output Function

Some built-in functions need to return more than a single value and do this by using one or more output parameters within the parameter list.  Built-in multiple output functions typically preface the parameter name with an 'o' to indicate that it is an output parameter used to return a value.  These are also known as 'input-output' parameters because they are declared within a function as a 'ref' type of  input (i.e. NumericRef, TrueFalseRef, etc.) which allows it output a value, by reference, to a variable in the EasyLanguage code calling the function.

For example, the following built-in function looks for the 2nd highest Close over the last 30 bars. The first four parameters are inputs used to specify 1) what price to find, 2) over how many bars,  3) which occurrence (1st, 2nd, etc.), and  4) look for the highest or lowest.  The fifth and sixth parameters are outputs.   It uses one output parameter to return the 2nd highest Close to Value2 and a second output parameter to return the number of bars ago it occurred to Value3.  The function itself returns the status of the search (1 if successful or -1 if an error occurred) to Value1.

Var: oExtremeVal(0), oExtremeBar(0);

Value1 = NthExtreme(Close, 30, 2, 1, oExtremeVal, oExtremeBar);

Value2 = oExtremeVal;

Value3 = oExtremeBar;

Wrapper Function

When looking at the EasyLanguage code for a built-in function you may find the term 'wrapper function'. This refers to a single-return function that references a multiple output function to obtain the return value.  Calling a single-return 'wrapper' function helps make your EasyLanguage code simpler by avoiding the need to set up output parameters or understand multiple output functions.  For example, the ADX function returns the average directional movement index value that is one of several output parameters of the DirMovement function.