Text Drawing
Text drawing is a feature that allows the drawing of text on charts to display trading information, important messages, and more.
The usage of text drawing functions mainly involves two actions:
- Creating a text object and obtaining a
TextID
:- Use the
Text_New
function to create a text object and obtain theTextID
for this text object. TextID
is a variable used to store the unique ID of a text object created by theText_New
function.
- Use the
- Operating on a text object with
TextID
:- With the
TextID
, you can perform various operations on the already created text, such as modifying, moving, or deleting it.
- With the
Var: textID(0);
// Create a text object and obtain the TextID,
// with the text being "Buy Signal" and the location set to 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)); // Set the text color to red
Text_SetFont(TextID, "Arial", 12, True, False); // Set the font to Arial, size 12, bold
Text_SetString(TextID, "Updated Text Here!"); // Update the text content
Text_New Function
API | Text_New(BarDate, BarTime, PriceValue, "Text") |
Explanation | Displays a text object, consisting of the specified string expression located at the specified bar and specified price value, on the chart that the study is based on. |
BarDate | – A numerical expression specifying the date of the bar at which the object is to be placed. – The date is indicated in the YYYMMdd format, where YYY is the number of years since 1900, MM is the month, and dd is the day of the month. |
BarTime | – A numerical expression specifying the time of the bar at which the object is to be placed. – The time is indicated in the 24-hour HHmm format, where 1300 = 1:00 PM. |
PriceValue | A numerical expression specifying the price value (vertical position, corresponding to a value on the price scale of a chart), where the object is to be placed. |
Text | The string expression to be displayed. |
Return | TextID ,the unique number represents this text object。 |
Example
The following code utilizes text drawing to visualize position information for recent closures on a chart, including profit, entry price, exit price.
vars:MP(0);
MP=marketposition*currentcontracts;
if MP=0 and MP[1]<>0 then begin
value1=TEXT_New(D, T, H,"");
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:

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