Instructions/probuilder

COLOURED

COLOURED applies a static or condition-driven color to a returned curve in ProBuilder indicators, using RGB components, named colors and optional alpha.

Syntax

probuilder
RETURN value COLOURED(R, G, B)
RETURN value COLOURED("colorname")

With transparency (platform version 10.3 and later):

probuilder
RETURN value COLOURED(R, G, B, alpha)

Dynamic coloring driven by a variable:

probuilder
RETURN value COLOURED BY (variable)

Parameters

NameTypeDefaultDescription
R, G, Binteger 0 to 255required in RGB formRed, green, and blue components of the curve color.
"colorname"stringrequired in named formPredefined color name recognized by ProRealTime™, such as "red".
alphainteger 0 to 255255Opacity, 0 fully transparent to 255 fully opaque. Available from version 10.3.
variablenumericrequired in BY formValue whose sign or level drives the color of each bar's segment.

How it works

COLOURED attaches color information to a value emitted by RETURN. In its static form, the whole curve takes one fixed color, defined either by three RGB components or by a predefined color name. From platform version 10.3 an optional fourth argument controls opacity on a 0 to 255 scale, allowing semi-transparent lines that do not obscure price.

The dynamic form, COLOURED BY, colors each segment of the curve according to a driving variable computed earlier in the script. As the variable changes value from bar to bar, the plotted line changes color along its length. The common pattern computes a state variable, for example 1 while a fast average is above a slow one and -1 otherwise, and lets the curve flip color at each regime change.

COLOURED modifies presentation only. The returned values are unchanged, and scripts that CALL the indicator receive the same numbers regardless of coloring. Because the mechanism rides on RETURN, it belongs to indicator code; strategy and screener programs do not plot curves and have no use for it.

Examples

Example 1, Trend-colored slow average (Indicator)

probuilder
i1 = average[10](close)
i2 = average[50](close)
// State variable: 1 when the fast average leads, -1 otherwise
IF i1 > i2 THEN
  a = 1
ELSE
  a = -1
ENDIF
RETURN i2 COLOURED BY (a)

The 50-period average is drawn in one color while the 10-period average is above it and switches to another when the relationship inverts, encoding trend direction directly on the line.

Example 2, Fixed color for a reference curve (Indicator)

probuilder
// Plot a 200-period average in a fixed orange
longTermMA = average[200](close)
RETURN longTermMA COLOURED(255, 140, 0) AS "MA 200"

A static RGB color distinguishes the long-term average from other lines on the chart without depending on the platform's automatic color assignment.

Example 3, Semi-transparent oscillator line (Indicator)

probuilder
// RSI drawn dark blue at roughly half opacity
r = RSI[14](close)
RETURN r COLOURED(0, 0, 139, 128) AS "RSI 14"

The fourth argument sets alpha to 128 of 255, so the oscillator remains visible without dominating anything plotted beneath it.

Common errors and gotchas

  • Alpha scale differs from ColorBetween. COLOURED opacity runs 0 to 255, while ColorBetween uses 0 to 100. Reusing a value across the two functions shifts the intended transparency.
  • Alpha needs version 10.3 or later. The four-argument form fails on older platform versions. The three-argument RGB form works everywhere.
  • British spelling. The keyword is written COLOURED, as documented. Spelling it COLORED is the most common typo when the function appears not to exist.
  • Presentation only. COLOURED changes how the curve is drawn, not its values. Conditional logic based on color is impossible; base conditions on the underlying variable instead.
  • ColorBetween, fills the area between two curves with a color.
  • BACKGROUNDCOLOR, colors the chart background bar by bar.
  • FILLCOLOR, fill color control for drawn shapes.
  • RETURN, emits the values that COLOURED decorates.
  • DRAWTEXT, prints text on the chart, another presentation tool.
  • STYLE, sets line style and thickness of plotted curves.
  • Average, moving average, a frequent target for conditional coloring.
  • RSI, oscillator often plotted with custom colors.