Writing Indicators

In Tradesignal, many indicators are available, either delivered with the software or offered for download from the website.

However, wishes may remain unfulfilled or you may have new ideas that need to be tested. In these cases, you can always program new indicators in Tradesignal by using the Equilla language.

In the following you will find an example showing how to write an indicator using Equilla. It is only intended to give you a basic introduction. For details on Equilla, please refer to the Equilla Basics chapters.

Programming Trading based on a Relative Strength Index


Writing a new indicator

Creating the Indicator

  1. In the toolbox, click on the Indicators button.
  2. In the Related Tasks area, select New Indicator.
  3. In the next dialog, select the option Use the Equilla Formula Language to write the indicator.
  4. Select a folder, e.g. "Tradesignal Files".
  5. Type the name "RSI-Bands".
  6. Click on Done.
Now you can enter the source code of the indicator in the Equilla Editor.

Entering the Meta Information

In the meta area, global information about the indicator and its display are entered. These are declared using meta tags.

Meta:
    Subchart(false);

Declaring the Input Parameters

In the input area, parameters are declared that can later be edited and changed by the user during indicator runtime. In this case, these are mainly a smoothing factor and the calculation period.

Inputs:
    Period( 20 , 1 ),
    Smoothing( 10 , 1 ),
    Factor( 1.0 );

Declaring the Variables

Variables are data containers in which the values of calculation results are temporarily saved and therefore available for future use.

Variables:
    rsiValue, upperBand, lowerBand, medLine;

Performing the Calculations

In this area, the actual calculations are done, whose results are displayed later. In our example, the continuous regression line is taken as mid-line. With it, the Relative Strength Index is calculated, which is a measure for the strength and dynamics of the trend. The actual bands result from simply adding and subtracting the RSI from the mid-line.

medLine = LinRegValue( Close, Smoothing, 0);
rsiValue = RSI( Close, Period );
upperBand = medLine + ( rsiValue * factor );
lowerBand = medLine - ( rsiValue * factor );

Inserting the Graph

Finally, the calculation results have to be displayed. This is usually done at the end of the indicator code.
DrawLine( medLine, "Average", StyleSolid, 1, black);
DrawLine( upperBand, "Upper", StyleSolid, 2, red );
DrawLine( lowerBand, "Lower", StyleSolid, 2, darkgreen );

The Complete Code

Meta:
    Subchart(false);

Inputs:
    Period( 20 , 1 ),
    Smoothing( 10 , 1 ),
    Factor( 1.0 );


Variables:
    rsiValue, upperBand, lowerBand, medLine;


medLine = LinRegValue( Close, Smoothing, 0);
rsiValue = RSI( Close, Period );
upperBand = medLine + ( rsiValue * factor );
lowerBand = medLine - ( rsiValue * factor );

DrawLine( medLine, "Average", StyleSolid, 1, black);
DrawLine( upperBand, "Upper", StyleSolid, 2, red );
DrawLine( lowerBand, "Lower", StyleSolid, 2, darkgreen );

Applying the Indicator

Compile the code either by pressing F7 or by clicking on the button Compile Script in the Equilla Editor group. The code is checked for errors, saved and then available in the list of indicators in the toolbox by the name "RSI-Bands".

You can now apply it to a chart as described in Using Indicators, for example with drag and drop.