Graphical/probuilder

DRAWTEXT

DRAWTEXT in ProBuilder prints a text label on the chart at a bar index and price, with optional font, style, size and COLOURED colour. Syntax and worked examples.

Syntax

probuilder
DRAWTEXT("text", x1, y1, font, style, size) COLOURED(R, G, B, a)

Parameters

NameTypeDefaultDescription
"text"stringrequiredThe text to display, in quotation marks. Variables can be embedded between # symbols.
x1integerrequiredBar index where the text starts.
y1pricerequiredPrice or vertical value where the text is placed.
fontkeywordDialogOptional font: Dialog, Monospaced, Serif, SansSerif.
stylekeywordStandardOptional style: Standard, Bold, Italic, BoldItalic. Requires font.
sizeinteger10Optional font size, 10 to 30. Requires font and style.
R, G, B, aintegerplatform defaultOptional COLOURED colour and alpha, 0 to 255 each.

How it works

DRAWTEXT runs inside a ProBuilder indicator. It prints a string on the chart anchored at (x1, y1), where x1 is a bar index and y1 is a price. It is used to annotate levels, values or conditions. A variable can be shown inside the text by wrapping its name in #, for example "High: #highPrice#" prints the value of highPrice.

The optional font, style and size arguments follow the coordinates, and each later one requires the ones before it. The COLOURED clause sets the text colour and transparency. For a single caption on the current bar, set DEFPARAM DrawOnLastBarOnly = true.

Examples

Example 1, Label the current high (Indicator)

probuilder
// Print "High Price" at the high of the current bar in red
highPrice = high
DRAWTEXT("High Price", BarIndex, highPrice) COLOURED(255, 0, 0, 255)
RETURN

The label sits at the high of each bar, coloured solid red.

Example 2, Embed a value in the text (Indicator)

probuilder
// Show the numeric high inside the label, once on the last bar
DEFPARAM DrawOnLastBarOnly = true
highPrice = high
DRAWTEXT("High: #highPrice#", BarIndex, highPrice, SansSerif, Bold, 12) COLOURED(0, 0, 0)
RETURN

The #highPrice# placeholder is replaced by the actual value, shown in bold 12-point SansSerif.

Example 3, Caption a drawn line (Indicator)

probuilder
// Draw a level and label it
DEFPARAM DrawOnLastBarOnly = true
lvl = Highest[20](high)
DRAWHLINE(lvl) COLOURED(0, 150, 0)
DRAWTEXT("20-bar high", BarIndex, lvl) COLOURED(0, 150, 0)
RETURN

DRAWTEXT names the level drawn by DRAWHLINE.

Common errors and gotchas

  • Indicator only. DRAWTEXT has no effect in ProScreener, ProOrder or ProBacktest. Keep it in a ProBuilder indicator.
  • Optional arguments are ordered. To set size you must also pass font and style before it. Skipping one shifts the rest.
  • Variable placeholders use #. To print a value, wrap the variable name in #. Writing the name plainly prints it as literal text.
  • X is a bar index. Passing a price into x1 misplaces the text horizontally. Use BarIndex.