EasyLanguage Object Reference
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