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 - 1, 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

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
Example