Help > 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:
Meta:
Subchart( false );
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 ( )
 |
Line example |
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:
Meta:
Subchart( true );
Variables:
mySinValue, counter;
mySinValue = Sin(counter);
counter = counter + 1;
DrawLine( mySinValue, "Sinus", StyleSolid,2, Red );
DrawForest ( )
 |
Forest example |
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:
Meta:
Subchart( false );
Inputs:
Period( 20, 1 );
Variables:
myOwnIndicator;
myOwnIndicator = RSI ( Momentum (Close, Period), 5 );
DrawForest( 0, myOwnIndicator, "Basis", "MEI", thick, blue, false );
DrawArea ( )
 |
Area example |
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:
Meta:
Subchart( true );
Variables:
counter, colorValue;
if counter <= 254 then
counter = counter + 1;
Else
counter = 0;
colorValue = RGB( counter, 150, 150 );
colorValue = TransparentColor ( colorValue, counter );
DrawArea( counter, Neg( counter ), "Up", "Down", colorValue, Black, Black);
DrawSymbol ( )
 |
Symbols example |
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):
Meta:
Subchart( false );
Inputs:
Period( 20, 1 );
Variables:
avgValue;
avgValue = XAverage ( Close, Period );
If Close Crosses over avgValue Then
DrawSymbol( High, "CrossUp", SymbolTriangleUp, 20, black, darkgreen);
If Close Crosses under avgValue Then
DrawSymbol( Low, "CrossUp", SymbolTriangleDown, 20, black, darkgreen);
DrawLine( avgValue, "Average", StyleSolid, 2, black );
DrawText ( )
 |
Output text example |
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:
Meta:
Subchart( false );
Inputs:
Period( 10, 1 );
Variables:
avgValue;
avgValue = WAverage ( Close, Period );
If TurnsUp( avgValue, 2, 1 ) Then
DrawText[1]( Low[1], "Up", "Bottom", 10, Darkgreen);
If TurnsDown( avgValue, 2, 1 ) Then
DrawText[1]( High[1], "Down", "Top", 10, Red );
DrawBar ( )
 |
Bar chart example |
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):
Meta:
Subchart( true );
Inputs:
Period( 14, 1 );
Variables:
avgOpen, avgHigh, avgLow, avgClose;
avgOpen = XAverage( Open, Period );
avgHigh = XAverage( High, Period );
avgLow = XAverage( Low, Period );
avgClose = XAverage( Close, Period );
DrawBar ( avgOpen, avgHigh, avgLow, avgClose, DarkGreen, Red );
DrawCandleStick ( )
 |
Candlesticks example |
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):
Meta:
Subchart( true );
Inputs:
Period( 14, 1 );
Variables:
haOpen, haHigh, haLow, haClose;
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 = MaxItems( high, haOpen, haClose );
haLow = MinItems( low, haOpen, haClose );
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:
SubChart( False );
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;
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
While ( ToolGetFirst() <> -2 )
ToolDelete( ToolGetFirst() );
highVal = HHV( Price, Period );
DrawTrendline( DateTime[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 );
If MarketPosition = MarketPositionLong Then
farbe = LongColor
Else If MarketPosition = MarketPositionFlat Then
farbe = FlatColor
Else If MarketPosition = MarketPositionShort Then
farbe = ShortColor;
While ( ToolGetFirst() <> -2 )
ToolDelete( ToolGetFirst() );
DrawRectangle( Date, 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
Meta:
Subchart( true );
Variables:
myFirstRGBColor, myFirstHSVColor;
myFirstRGBColor = RGB( 100, 30, 250 );
myFirstHSVColor = HSV( 100, 230, 250 );
DrawLine( 100, "RGB color", StyleSolid, 5, myFirstRGBColor );
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.
Meta:
Subchart( true );
Inputs:
Transparency( 200, 1 );
Variables:
myFirstRGBColor, MyFirstTransparentColor;
myFirstRGBColor = RGB( 100, 30, 250 );
myFirstTransparentColor = TransparentColor( myFirstRGBColor, Transparency );
DrawArea( 100, -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.
Variables:
myDate, myFutureDate;
myDate = FormatDate( DateTime, "dd.mm.yyyy");
myFutureDate = FormatDate( DateTime, "dd.mm.yyyy")[-1];
Print( "I'm just editing the: " + myDate + ", after that, " +
myFutureDate + " 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: " +
FormatDate( DateTime, "yyyy/mm/dd"));
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( fileName );
PrintToFile( fileName, "Indicator was last used at: " +
FormatDate( DateTime, "yyyy/mm/dd"));
End;
Alert Output
 |
An Alert Window |
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;