Equilla Quick Start

Equilla Program Structure and Syntax

Meta Tags

The so-called meta properties define the global functions of your indicator, for example if the indicator should be displayed in a window of its own or within another chart. You can also add information about how the indicator is calculated (Synopsis) and define a ShortCode. The meta information area can usually be found in the beginning of the source code. You should adhere to this convention. The area has to be introduced with the tag


The three most important pieces of meta information are:

    //Description for the code
    Synopsis" Text " ), 
    //Define whether the indicator will be displayed in a separate sub-chart or not
    //Define a ShortCode. By entering it in the command linethe indicator is called up.

Input Declaration

When applying an indicator to a chart, one or more parameters are available in the indicator properties. These parameters can be calculation periods, multiplications or lists. User-specific parameters have to be declared in the input area of the source code. The area has to be introduced with the tag


Available Input Types


    //Switch for true/false /yes/no) choice.
    Visuals (true, false),

    //Input field for integers, followed by lower and upper
    //end of range.
    Period(10, 1, 100),

    //Input field for decimal value; note that the 
    //decimal point of the defining criterion.
    FactorOffSet( 1.25, 1.0, 5.0 ),

    //Input field for string; note that 
    //the quotation marks are the defining criterion.
    UserName( "John Smith" ),

    //Input field for colors; the dialog is system-dependent.
    //The dialog generation also works for colors entered as
    //RGB values ( redValue, greenValue, blueValue ).
    //The values for redValue, greenValue und blueValue have to be between
    //0 and 255.
    PreferredColor( red ),

    //Generates a selection list for time lines. The list automatically
    //includes all time lines for the basic symbol. Usually, these are the 
    //Open, High, Low, Close and Volume data.
    PriceValue( Close ),

    //Generates a selection list for the given words or strings.
    //The list is zero-based.
    Weekdays( Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday );

Examples for Using the Input Types

//Example for querying a true/false (yes/no) boolean switch

//When the switch is set to true (yes), a line is drawn:
If Visuals = True Then
    DrawLine ( (High+Low)/2);

//Example for using an integer input
//The parameter 'Period' is declared as input, the given
//value 10 for the period is passed to the average function.
avgValue = AverageClose, Period );
Drawline( avgValue );

//Example for using a decimal number
//The drawing function draws a continuous line which
//corresponds to the value 'close * 1.25'.
DrawLine( FactorOffSet * Close );

//Example for using a string input
//In the output window, 'John Smith' is displayed.
Print"UserName" );

//Example for using a color value as input
//A red, solid line is drawn.
DrawLineClose, "Close Line", StyleSolid, 2, PreferredColor );

//Example for using a time line input
//A line is drawn on the level of the close prices.
DrawLine( PriceValue );

//Example for querying the selected entry in a list
//In the output window, 'Monday' appears when selected.
If Weekdays = "Monday" Then
    Print"Monday" );

//In lists, index numbers are assigned to the entries. 
//As already mentioned, lists are zero-based, so Monday is "0" and Sunday is "6".
//Instead of querying the string, the index number can be used instead. 
If Weekdays = 0 Then
    Print"Monday" );

Variable Declaration

What are Variables?

Variables are data containers. To be able to use values like numbers, calculation results, user entries or prices, the values have to be saved temporarily in variables. This way, each value has its own storage space and can be called up by the variable name. Imagine variable to be like containers on a cargo ship. Each container has its own unique ID, with which to find the contents. When the booker needs to know the information in a container, he enters the unique ID into a computer, which returns the wanted information.


Validity of Variables

Variables are only valid within the script in a chart. It is not possible to use the value of variable "Period1" of the indicator "Indicator1" in "Indicator2", since the second script has no access to the variable - not even when both indicators are used in the same chart. 

The only exceptions to the rule are global variables.

Initialization of variables, and for how long do they keep their value?

Each Equilla script, e.g. an indicator, is processed once for each trading period. If the indicator is used in a daily chart, the indicator is calculated once for each day in the chart. The variable is initialized at the first trading day in the chart.

If in the days following that, no new value is set for the variable, the value is kept until the last trading day in the chart. If a new value is set for the variable in between, it is kept until a new value is assigned or until the last trading day.

Generating Variables

Variables are generated by being declared, i.e. given a name. Variables can only be defined within a certain code area. It has to be introduced with the tag


You have the following possible methods to declare a variable:

//Declare a variable by assigning a name
    myFirstVariable, mySecondVariable;
//Declare a variable by assigning a name and value
    myFirstVariable( 10 ), mySecondVariable( myFirstVariable / 2 );

//Declare a variable by entering a string
    myFirstString ( "" ), mySecondString( "String test" );

//Declare a variable with color values
    myFirstColor( red ), mySecondColor( RGB (10, 20, 30) );

Global (Script-independent) Variables

As opposed to the statement above, you can use global variables under special circumstances. The limitation is that the scripts have to be in the same chart or portfolio. A sub chart, for example an indicator chart, does not count as a full chart. Therefore, you can pass data between main and sub charts and between several Equilla scripts that are used within the same main/sub charts.

To do so, global variables are available. A global variable consists of a "Namespace", which can be seen as the name of the cargo ship, and a variable name, which can be seen as the container ID. Since global variables are valid across several scripts, they do not have to be defined in the "Variables:" area. It is enough to name the global variable in one script and assign a value this way. 

//This is the way to set up a global variable
//The global variable with the Namespace 'global' and the name
//'myFirstGlobalVar' is generated by assigning a value.
//From this moment on, the value can be used in all 
//scripts in the same chart.
global::myFirstGlobalVar = 100;

//This is the way to read the value of a global variable.
//In the output window, '100' is displayed.
myNewVar = global::myFirstGlobalVar ;
Print( myNewVar );

Declaration Detail for Variables and Inputs

For variables as well as inputs, you can either enter several declarations in one line or each declaration in its own line. The declarations have to be separated by commas. After the last declaration, a semi-colon has to be entered.

//Declare inputs in one line
    MyName( "Caspar David" ), YourName( "Peter King" ), HerName ( "Barbara Myers" );

//Declare inputs in several lines
    MyName( "Caspar David" ), 
    YourName( "Peter King" ), 
    HerName ( "Barbara Myers" );

Structuring Source Code

For a better readability and overview in the Equilla code, the source code should be well-structured. This also makes it easier to find errors in the coding. For structuring, make use of indentions, comments and empty lines. Declare the variables and inputs in separate lines instead of one line.

Indenting Source Code

It is a standard programming technique to indent certain parts of the code by using the Tab key. This way it is much easier to understand the relations between code parts. This is especially useful in cases of loops or conditions.

//Indenting the code that is only run if the condition is met
If Bronto = "Saurus" Then
    DrawTextClose, "Run away!" );
//Cascading indenting of code to keep a better overview
If condition = "met" Then
        myFirstVar = 100;
        mySecondVar = 7;
        DrawLine( myFirstVar + mySecondVar );
//Each consecutive condition should also be indented 
If condition = "met" Then
        myFirstVar = 100;
        mySecondVar = 7;
        //additional condition
        if Visuals = True Then
            DrawLine( myFirstVar + mySecondVar );



Bracketing Expressions

It is also recommended that you use bracketing for conditional queries or loops. This way, you avoid overly complicated code and malfunctioning which may result from logical errors. 

//Expressions in queries should be bracketed for two reasons
//a) For better overview
If ( myFirstVar = 100 ) and ( mySecondVar = 100 ) Then
        //Here follow...

//b) For program logic 
If (myFirstVar = 100AND ((mySecondVar = 100OR (myThirdVar = 0)) Then 
        //This block is only executed if
        //myFirstVar and mySecondVar both have the value 100
        //or if myFirstVar has the value 100 and if myThirdVar has the value 0 

Take a closer look at the second example. If the two brackets around the expressions linked by OR were not there, another meaning would result. The condition would be met if "myFirstVar = 100 and mySecondVar = 100" OR "myThirdVar = 0". In this case, the code would only be executed if "myFirstVar" were 100 and "mySecondVar" were 100 OR "myThirdVar" were 0, which was not meant to be according to the definition given in the comments.

In addition to the examples above, it may also be useful to set brackets around mathematical operators. 

//Are you sure what's meant here?
myFirstVar = 100 * ( x + y * ( 10 / z ) );

//This way it is easier to read.
myFirstVar = 100 * ( x + ( y * ( 10 / z ) ) );

Inserting Comments

As already seen, you can enter comments in the code. This is especially useful for two reasons

  • Even in case of longer source code and more complex structures, good readability and comprehensibility are given. This way, you can correct or edit the code even after years.
  • Outsiders are able to understand the code much faster.

//This is a single line comment

avgValue (Open// You can also add a comment at the end of the line

/*This is the start of a multiple line comment Comments are disregarded by the program interpreter, they are only displayed in the editor. With comments program parts can be deactivated for example for error search. ---This assignment of a calculation to a parameter is not executed Value1 = XAverage( Close, 10 ); This is the end of the comment */


BACK TO OVERVIEW      Equilla Functions