Text Drawing#

Text drawing allows you to display trading information and messages on the chart. Common text drawing functions include create and delete, set text content and location, and set appearance.

The usage of text drawing functions mainly involves two actions:

  1. Create a text object and obtain the TextID: Use the Text_New function to create a text object, which returns the unique ID of this text object, stored in the variable TextID.
  2. Operate on the text object using TextID: With the TextID, you can perform various operations on the already created text, such as modifying, moving, or deleting it.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
Variables: TextID(0);

// Create a text object and obtain the TextID, with the text "Buy Signal" at the current date, time, and closing price
TextID = Text_New(Date, Time, Close, "Buy Signal");

// Operate on the text object using TextID
Text_SetColor(TextID, RGB(255, 0, 0));
Text_SetFontName(TextID, "Arial");
Text_SetSize(TextID, 12);
Text_SetAttribute(TextID, 1, true);
Text_SetString(TextID, "Updated Text Here!");

Example#

The following code uses text drawing to display the position information (profit, entry price, exit price) of the last closed position on the chart.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
Variables: MP(0);

MP = MarketPosition * CurrentContracts;

If MP = 0 and MP[1] <> 0 Then Begin
  Value1 = Text_New(Date, Time, High, "");
  Text_SetString(Value1,
    "+$" + NumToStr(PositionProfit(1), 3) + NewLine
    + "EntryPrice: " + NumToStr(EntryPrice(1), 3) + NewLine
    + "ExitPrice: " + NumToStr(ExitPrice(1), 3) + NewLine
    + "PositionProfit: " + NumToStr(PositionProfit(1), 3) + NewLine
    + "OpenPositionProfit: " + NumToStr(OpenPositionProfit, 3)
  );
  Text_SetStyle(Value1, 2, 1);
  Text_SetColor(Value1, RGB(232, 232, 0));
  Text_SetFontName(Value1, "Showcard Gothic");
  Text_SetSize(Value1, 14);
  Text_SetAttribute(Value1, 1, true);
  Text_SetBorder(Value1, true);
  Text_SetLocation(Value1, Date, Time, High + 200);
End;

The above code will produce output similar to the following:

Common Text Drawing Functions#

The return value of text drawing functions is 0 for success, and -2 for an invalid ObjectID.

Create and Delete#

Text_New(BarDate, BarTime, PriceValue, "Text")#

Creates a text object on the chart at the specified bar and price, and returns the TextID of this text object.

ItemDescription
BarDateNumerical, specifies the date of the bar at which the object is to be placed. The date is in YYYMMdd format, where YYY is the number of years since 1900, MM is the month, and dd is the day
BarTimeNumerical, specifies the time of the bar at which the object is to be placed. The time is in 24-hour HHmm format, e.g., 1300 = 1:00 PM
PriceValueNumerical, specifies the vertical position of the text object, corresponding to a value on the price scale of the chart
TextThe string to be displayed
Return valueTextID, the unique ID of this text object

Text_Delete(ObjectID)#

Deletes the specified text object.

ItemDescription
ObjectIDThe ID of the text object

Set Text Content and Location#

Text_SetString(ObjectID, "Text")#

Sets the string displayed by the text object.

ItemDescription
ObjectIDThe ID of the text object
TextThe string to be displayed

Text_SetLocation(ObjectID, BarDate, BarTime, PriceValue)#

Sets the location of the text object. Parameter formats are the same as Text_New.

ItemDescription
ObjectIDThe ID of the text object
BarDateBar date, YYYMMdd format
BarTimeBar time, 24-hour HHmm format
PriceValueVertical position, corresponding to a value on the price scale of the chart

Set Appearance#

Text_SetColor(ObjectID, TextColor)#

Sets the color of the text.

ItemDescription
ObjectIDThe ID of the text object
TextColorColor value, can use RGB(R, G, B) or a color name (e.g., Blue)

Text_SetBGColor(ObjectID, BGColor)#

Sets the background color of the text.

ItemDescription
ObjectIDThe ID of the text object
BGColorBackground color value, can use RGB(R, G, B) or a color name

Text_SetFontName(ObjectID, "FontName")#

Sets the font of the text. Any font installed on Windows can be used.

ItemDescription
ObjectIDThe ID of the text object
FontNameFont name, e.g., "Arial", "Verdana"

Text_SetSize(ObjectID, FontSize)#

Sets the font size of the text.

ItemDescription
ObjectIDThe ID of the text object
FontSizeFont size

Text_SetStyle(ObjectID, HorizPl, VertPl)#

Sets the alignment of the text object relative to the bar and price.

ItemDescription
ObjectIDThe ID of the text object
HorizPlHorizontal alignment. 0: right of the bar. 1: left of the bar. 2: center of the bar
VertPlVertical alignment. 0: below the price. 1: above the price. 2: center of the price

Text_SetAttribute(ObjectID, Attribute, LogicalExpression)#

Sets the style attribute of the text.

ItemDescription
ObjectIDThe ID of the text object
Attribute0: border. 1: bold. 2: italic. 3: strikethrough. 4: underline
LogicalExpressiontrue: enable. false: disable

Text_SetBorder(ObjectID, LogicalExpression)#

Sets whether the text object displays a border. The border color is the same as the text color.

ItemDescription
ObjectIDThe ID of the text object
LogicalExpressiontrue: show border. false: hide border

Reference#

https://www.multicharts.com/trading-software/index.php?title=Category:Text_Drawing

© 2026 CodeReindeer. All rights reserved.