EasyLanguage Object Reference

TextLabel Class

Displays a single line of text on a chart at a specified location. Appearance may altered using appropriate properties. The TextLabel object is a non-analytical drawing tool used to hold free-form text such as comments or notes.

A TextLabel can be displayed at a fixed X-Y location in the chart window using XYPoint, or at a bar-based location using BNPoint or DTPoint. A bar-based location will anchor the text starting point to a specific bar interval so that it will move with the bars when the chart is scrolled compared to text created with an XY point that remains at a fixed location in the chart window even when the chart is scrolled.

The code snippet below shows how place text at a specific X-Y point in the chart window 150 pixels from the left edge of the chart at 50 pixels down from the top. Note that the XYPoint is created directly as a TextLabel parameter without using a separate XYPoint object. Refer to About Drawing Objects for more information.

myXYText = TextLabel.Create(XYPoint.Create(150,50),"Some text goes here.");
DrawingObjects.Add(myXYText);

Alternatively, you can use BNPoint to plot text at a specific bar number or DTPoint to plot at a date-time position, so that the text label will scroll with the bars:

If (Currentbar = 50) then
Begin
   MyBNText = TextLabel.Create(BNPoint.Create(CurrentBar + MaxBarsBack, High),"50 Bars Back");
   DrawingObjects.Add(MyBNText);
End;
If (LastBarOnChart = True) then
Begin
    MyDTText = TextLabel.Create(DTPoint.Create(BarDateTime[25], High, "25 Bars Back"));
    DrawingObjects.Add(MyDTText);
End;

To change the text font, create a font object with the desired font family name and point size and assign it to the Font property as in the following example. See Font class for additional information.

myFont = elsystem.drawing.Font.create("Arial",10);
myText.Font = myFont;

Namespace: elsystem.drawingobjects

[ Expand All ]
Properties

   Additional properties, methods, and events are described in the classes listed under Inheritance Hierarchy (see below).

  Name Type Description
Public property Font object Gets or sets the font object used to set font parameters. See Font class for more details.
Public property HStyle enum Gets or sets the horizontal position of the text relative to the anchor point. See HorizontalStyle enumerated list.
Public property PointValue object Gets or sets the DrawingObject point, initially set in the Create method. The DOPoint object allows changes to the Price (but NOT the PointType).
Public property TextString string Gets or sets the text string to be displayed. TextString will overwrite any text in TextLabel.Create(DTPoint, "some text");
Public property VStyle enum Gets or sets the vertical position of the text relative to the anchor point. See VerticalStyle enumerated list.
Methods
  Name Description
Public property Create(DTPoint, string) Initializes a new instance of the TextLabel class.  The first parameter is a DTPoint object representing the location of the text; the second parameter is the string to be displayed.
Public property Create(DTPoint, string, datanum) Initializes a new instance of the TextLabel class.  Parameters include a DTPoint pointvalue representing the position of the text, the text string to be displayed, and an integer representing the datanum on which to display the text.
Public property Create(BNPoint, string) Initializes a new instance of the TextLabel class.  Parameters include a BNPoint object representing the location of the text and the string to be displayed.
Public property Create(BNPoint, string, int) Initializes a new instance of the class using the BNPoint object, text string, and the data number.
Public property Create(XYPoint, string) Initializes a new instance of the TextLabel class using the XYPoint object, and text string.
Public property Create(XYPoint, string, int) Initializes a new instance of the TextLabel class using the XYPoint object, text string, and the data number.
Example

The following example shows...  

Import Example

Displays a rectangle containing text at a fixed position in the upper-right corner of a chart.

  1. Click on the Import Example link to import the example into TradeStation.   
  2. Go to the TradeStation platform and create a chart window.  Use the Insert - Indicator menu sequence and Add !ex_TextRectangle to the window.
  3. To review or modify the example code, go to the TS Development Environment and open indicator !ex_TextRectangle in the EasyLanguage Editor.
Inheritance Hierarchy

elsystem.Object

  elsystem.DrawingObject

    elsystem.DrawingObjects.TextLabel