Support

        Equilla Quick Start

Equilla Graphs, Outputs and Alerts

There are several ways to offer data, calculation results, symbols and reports to the users. One of the most important functions is the graphic display of indicators and other information. Tradesignal offers output functions for text and reports and an alert function. 

For all Equilla operators, you can find additional information in Tradesignal. To display it, open the source code in the Equilla Editor. Then right-click on the operator in question, e.g. Begin, and choose Lookup Equilla Function from the context menu. A window opens with information on the operators and links to related functions.

Drawing Lines, Areas, Symbols or Text in a Chart

With the drawing statements, usually indicators and graphs related to them are generated. An indicator usually consists of a line or histogram. Some indicators also use filled areas or symbols or offer information as text. 

In this chapter, you can find general information on using colors, line width, symbols and their most important applications. When you enter a drawing statement in the editor, you can find all parameters and their sequence in the tooltip. Parameters that are not mandatory are labeled with "optional".

Basics of Drawing Statements

Here you can find information on using drawing statements, why they should have captions and how the displacement function can be used to move the graphic display in the timeline. The most important parameters are given.

Captions

A caption should be entered for each statement. This is especially useful when several drawing statements are used in the same chart. The captions have two important functions:

The drawing statements are more easily identified in the property inspector.

In the tooltips and the target cursor mode in the chart, values are displayed for all graphic objects under the cursor. The value interpretation is easier when the drawing statements are named.

If no caption is given, each drawing statement is labeled with "Plot" and a consecutive number.

Displacement

Displacement example

Equilla scripts are executed once per bar. By using so-called displacements, for example "Price[i]", you can retrieve older function results. In a similar way, drawing statements can be displaced. For this, the Displacement parameter has to be added directly after the statement. Enter a positive value in square brackets [ ] to move it into the past, and a negative value to move it into the future.

Example for a displacement:

// Generate no subchart
Meta:
    Subchartfalse );

//Execute at last bar
If isLastBar Then
    Begin
        DrawSymbol[3] (Low[3], "Past", SymbolSquare, 30, black, blue );
        DrawSymbol[-3] (Low, "Future", SymbolSquare, 30, black, blue );
    End;

Parameters

For all drawing statements, optional parameters can be specified. These are caption, line width, symbol size, colors etc. These parameters can be given by variables which can be changed at runtime (see some of the examples below). Feel free to experiment with the options. 

Especially interesting is using dynamic color values. Each component of the color values of RGB and HSV modes can be changed. The opacity can also be set. 

Design parameters like line or symbols styles can also be entered numerically. However, while this saves space, the full parameter names are easier to read and remember.


Drawing Statements and Syntax

Below, the most commonly used drawing statements and their syntax are listed. In the thumbnails, screenshots with graphs and source code are given.


DrawLine ( )

With this statement, a line is drawn. Style, size and color can be specified. Constant values or definable parameters (e.g. results or calculations) can be used. 

DrawLine[ Displacement ]( Value, "caption", Style, LineWidth, Color ); 

Example for a sine curve:

// Generate subchart
Meta:
    Subcharttrue );

//Declare variables
Variables: 
    mySinValue, counter;
    
//Assign a value to the variable
mySinValue = Sin(counter);
counter = counter + 1;

//Draw the values as a solid red 2 pixel line
DrawLine( mySinValue, "Sinus", StyleSolid,2, Red );


DrawForest ( )

With this statement, a forest graph (histogram) is drawn. Typically the start value is the base line. The color, start and end point of needles can be specified. This way, not only can indicators be drawn but the forest can also be used for generating grids. 

DrawForest[ Displacement ]( StartValue, EndValue, "caption1", "caption2", 

NeedleSize, NeedleColor, LinkForest True/False );

Example for an indicator displayed as forest:

// Generate no subchart
Meta:
    Subchartfalse );

Inputs: 
    Period( 20, 1 );

//Declare variables 
Variables: 
    myOwnIndicator;
    
//Create the indicator
myOwnIndicator = RSI ( Momentum (Close, Period), 5 );

//Display indicator as forest
DrawForest0, myOwnIndicator, "Basis", "MEI", thick, blue, false );


DrawArea ( )

With this statement, an area is drawn between two values of the scale. Colors and opacity can be set.

DrawArea[ Displacement ]( Value1, Value2, "caption1", "caption2", FillColor, 

LineColor1, LineColor2 ); 

Example for drawing an area with color gradient:

// Generate a subchart
Meta:
    Subcharttrue );

//Declare variables
Variables: 
    counter, colorValue;
        
//Change the counter in a loop 
if counter <= 254 then
    counter = counter + 1;

//Reset the counter at 255
Else 
    counter = 0;
    
//Set the RGB color value with a dynamic value.

colorValue = RGB( counter, 150, 150 );

//Set opacity.

colorValue = TransparentColor ( colorValue, counter );

//Draw the area between the positive and negative values of
//'counter', with black border lines. 

DrawArea( counter, Neg( counter ), "Up", "Down", colorValue, Black, Black);


DrawSymbol ( )

With this statement, symbol charts with circles, start, dots, triangles etc. can be drawn. The size and colors can be controlled dynamically.

DrawSymbol[ Displacement ]( Value, "caption", SymbolStyle, SymbolSize, 

SymbolBorderColor, SymbolFillColor ); 

Example for drawing triangles (pointing up or down, depending on the curves):

// Generate no subchart
Meta:
    Subchartfalse );

//Declare input
Inputs: 
    Period( 20, 1 );

//Declare variables
Variables: 
    avgValue;
    
//Calculate the average close price 
avgValue = XAverage ( Close, Period );

//Display an triangle pointing upward, if 
//the price crosses above the average.
If Close Crosses over avgValue Then
    DrawSymbolHigh, "CrossUp", SymbolTriangleUp, 20, black, darkgreen);

//Display an triangle pointing downward, if 
//the price crosses below the average.
If Close Crosses under avgValue Then
    DrawSymbolLow, "CrossUp", SymbolTriangleDown, 20, black, darkgreen);

//The average itself is displayed as line.

DrawLine( avgValue, "Average", StyleSolid, 2, black );


DrawText ( )

With this statement, text is output. Variables like font size, color, style etc. can be specified.

DrawText[ Displacement ]( Value, "caption", textoutput, FontSize, FontColor, 

FontStyle, URL ); 

Example for text output:

//Generate no subchart
Meta:
    Subchartfalse );

//Declare input
Inputs: 
    Period( 10, 1 );

//Declare variables
Variables: 
    avgValue;
    
//Calculate the average close price 
avgValue = WAverage ( Close, Period );

//When the average turns up, text is added to the 
//Low of the last day. 
If TurnsUp( avgValue, 2, 1 ) Then
    DrawText[1]( Low[1], "Up", "Bottom", 10, Darkgreen); 

//When the average turns down, text is added to the 
//High of the last day. 
If TurnsDown( avgValue, 2, 1 ) Then
    DrawText[1]( High[1], "Down", "Top", 10, Red ); 

 

DrawBar ( )

With this statement, a bar chart is drawn. Each of the four values - open, high, low, close - can be chosen freely. This way, indicators can also be drawn as bars.

In this statement no caption needs to be specified, as it can only be used once in each script.

DrawBar[ Displacement ]( Open, High, Low, Close, BullishColor, BearishColor ) 

Example for modified OHLC values as bars (Heikin Ashi method):

//Generate a subchart
Meta:
    Subcharttrue );

//Declare input
Inputs: 
    Period( 14, 1 );
    
//Declare variables
Variables: 
    avgOpen, avgHigh, avgLow, avgClose;

//Calculate the average for all quotes. 
avgOpen = XAverageOpen, Period ); 
avgHigh = XAverageHigh, Period ); 
avgLow = XAverageLow, Period ); 
avgClose = XAverageClose, Period ); 

//Display bars.
DrawBar ( avgOpen, avgHigh, avgLow, avgClose, DarkGreen, Red );


DrawCandleStick ( )

With this statement, a candlestick chart is drawn. Each of the four values - open, high, low, close - can be set freely. This way, indicators can also be drawn as candlesticks. 

In this statement no caption needs to be specified, as it can only be used once in each script.

DrawCandleStick[ Displacement ]( Open, High, Low, Close, BullishColor, BearishColor, 

BorderColor )

Example for modified OHLC display as candlesticks (Heikin Ashi method):

//Generate a subchart
Meta:
    Subcharttrue );

//Declare input
Inputs: 
    Period( 14, 1 );
    
//Declare variables
Variables: 
    haOpen, haHigh, haLow, haClose;

//Calculate the Heikin Ashi values
If ( CurrentBar = 1 ) Then
    Begin
        haOpen = Open;
        haClose = Close;
    End
Else
    Begin
        haOpen = (haOpen[1+ haClose[1]) / 2);
        haClose = (open + high + low + close/ 4);
    End;
    
haHigh = MaxItemshigh, haOpen, haClose );
haLow = MinItemslow, haOpen, haClose );

//Draw the Heikin Ashi values as candlesticks.
DrawCandlestick ( haOpen, haHigh, haLow, haClose, DarkGreen, Red, DarkGray );


DrawPriceMarker ( )

This draws a horizontal marker at the given price next to the price scale or aligned to the last bar. Price markers will only be drawn on the last bar of a chart. Additionally, price markers are only valid for one evaluation run. When an update occurs, all existing price markers will be deleted. Price markers are always drawn behind any other chart.

DrawPriceMarker( Price1, Price2, Width, FillColor, BorderColor, BorderThickness, Alignment, Label, LabelSize, LabelColor, LabelOptions )

In contrast to drawing functions like DrawLine(), DrawPriceMarker () does not procure series data. Therefore the output from this function cannot be used from client scripts.Example for markers for all stop and limit order active on the current bar:

Meta:
SubChartFalse );
    
Variables: 
order, price, type, extent( 10 );
    
If IsLastBar Then Begin
For order = 1 To GetActiveOrderCount Begin
price = GetActiveOrderPrice( order );
type = GetActiveOrderType( order );
If type = OrderTypeLimit Then
DrawPriceMarker( price, price, extent, Blue, Blue )
Else If type = OrderTypeStop Then
DrawPriceMarker( price, price, extent, Red, Red );
End;
End;

Drawing Tools with Special Functions

For the two drawing tools DrawTrendLine() and DrawRectangle(), special functions are available in Equilla to draw with and manipulate these tools.

These special functions are passed as (tool) flags. They allow actions, for example expanding a rectangle into the "past" with "ToolLeftExtend". 

In contrast to drawing functions like Drawline(), the output generated by the tool functions is valid for display in a chart only.

You can find more information on DrawTrendLine(), DrawRectangle() and the flags in Tradesignal help under Equilla Formula Language, menu entry Tools.


DrawTrendline ( )

This draws a trendline into a chart.

DrawTrendline( StartDate, StartTime, StartPrice, EndDate, EndTime, EndPrice, Style, Width, Color, Flags )

The flags are special functions like ToolExtendLeft, ToolExtendTop etc.

Example for a trendline drawn at the highest high of the last bars:

Input: 
Price( High ),
Period( 10, 1 );

Variables: 
highVal;

If IsLastBar Then
Begin
// Remove any trendline from the previous bars
While ( ToolGetFirst() <> -2 )
ToolDeleteToolGetFirst() );
    
    // calculate the highest high 
highVal = HHV( Price, Period );
    
    // draw the trendline
DrawTrendlineDateTime[10], highVal, DateTime, highVal );
End;

 

DrawRectangle ( )

This draws a rectangle into the chart.

DrawRectangle( StartDate, StartTime, StartPrice, EndDate, EndTime, EndPrice, BorderColor, FillColor, Flags )

The flags are special functions like ToolExtendLeft, ToolExtendTop etc.

Input: 
LongColor( ColorGreen ),
FlatColor( Transparent ),
ShortColor( ColorRed );
    
Variables: 
color, 
flags( ToolDrawInBackground + ToolExtendBottom + ToolExtendLeft + ToolExtendRight + ToolExtendTop );

// Select the background color
If MarketPosition = MarketPositionLong Then
farbe = LongColor
Else If MarketPosition = MarketPositionFlat Then
farbe = FlatColor
Else If MarketPosition = MarketPositionShort Then
farbe = ShortColor;

// Remove all previously drawn rectangles
While ( ToolGetFirst() <> -2 )    
ToolDeleteToolGetFirst() );

// Draw a rectangle in the background

DrawRectangleDate, Time, Close, Date, Time, Close, color, color, flags );


Change the Chart Type of an Indicator/Strategy

You can change the output of an indicator or strategy in a chart (which is using one of the drawing functions described above) without changing or recompiling the script. For this, select the indicator or strategy and open the Chart Types button menu in the Chart group in the toolbar. Then select the new chart type from the list.

Small Excursion in Chromatics

In Equilla, there are several ways to enter colors. A number of color definitions can be entered as names. The usual ones are the standard colors like red, darkgreen, blue, black, magenta etc. The list of predefined colors offers many more colors.

Beyond that, the two color models HSV and RGB are available. When you define a color, for example in the color dialog in the property inspector, the RGB and HSV values are given below the color areas. With these values, every possible color can be entered.


The Two Color Models

//Ouput in a subchart
Meta:
    Subcharttrue );

//Color values can be saved in variables
Variables: 
    myFirstRGBColor, myFirstHSVColor;

//Color as RGB value
myFirstRGBColor = RGB100, 30, 250 );

//Color as HSV value
myFirstHSVColor = HSV100, 230, 250 );

//Lines in RGB color 
DrawLine100, "RGB color", StyleSolid, 5, myFirstRGBColor );

//Lines in HSV color
DrawLine-100, "HSV color", StyleSolid, 5, myFirstHSVColor );

 

Using Opacity (Transparency)

For every color, you can define an opacity value. This works for all colors, the standard colors as well as colors given by RGB or HSV values. Once again, color values can be given by variables which can be combined with opacity.

//Open a subchart
Meta:
    Subcharttrue );

//Change this input value to see the opacity 
//effect in the chart
Inputs: 
    Transparency( 200, 1 );

//Color settings can be given as variables
Variables: 
    myFirstRGBColor, MyFirstTransparentColor;

//Compose an RGB value 
myFirstRGBColor = RGB100, 30, 250 );

//Add Opacity
myFirstTransparentColor = TransparentColor( myFirstRGBColor, Transparency );

//Draw an area with a transparent fill color
DrawArea100, -100, "Up", "Down", myFirstTransparentColor, black, black );

 

Output of Data in the Output Window

The output window is used for the output of data or text with the Print statement. For example, you can output your own statistical or temporary results.

As a developer, it is often necessary to have detailed information about the program flow. With the Print function, a parameter output can be generated (emulating a debug mode) that helps finding eventual errors.

//Let the program communicate
Variables: 
    myDate, myFutureDate;

myDate = FormatDateDateTime, "dd.mm.yyyy");
myFutureDate = FormatDateDateTime, "dd.mm.yyyy")[-1];

Print"I'm just editing the: " + myDate + ", after that, " +
myFutureDate + " will be next.");

/* In the output window, the following appears: I'm just editing the: 2007/06/12, after that, 2007/06/14 will be next. */

Data Output via File Interface

Tradesignal offers the option to write data directly into a file. You can find the setting for the target folder of the PrintToFile function in the Tradesignal Options, tab Equilla. In the statement, only the file name can be specified.

Variables: 
    fileName("UserStat.txt");

if isLastBar Then
    PrintToFile( fileName, "Indicator was last used at: " + 
FormatDateDateTime, "yyyy/mm/dd"));
/* A file is created with the entry: 'Indicator was last used at 2006/04/30' */

As long as you do not change or delete the file, Tradesignal appends each new line to the end of the file. This way, a history of entries results. If you want to ensure by way of a script that an existing file is used, you can delete that file.

Variables: 
    fileName("UserStat.txt");

if isLastBar Then
    Begin
        //RemoveFile deletes the file
        RemoveFile( fileName );
        PrintToFile( fileName, "Indicator was last used at: " + 
FormatDateDateTime, "yyyy/mm/dd"));
    End;
/* A file is created with the entry: 'Indicator was last used at 2006/04/30' At each start of the indicator, the existing file is deleted first. */

Alert Output

General information on how to set up and use the alert function can be found in Alerts. You also have the option to output alerts via Equilla. Please note that an alert is only output if generated at the last bar of the chart. Therefore it does not matter at which position in the script the alert function is placed, since it is only executed when the last bar is reached. 

Variables: 
    myAlertText("");

If isLastBar Then
    Begin
        myAlertText = "The prices break down!"
        alert( myAlertText );
    End;

 

BACK TO OVERVIEW      Equilla Arrays