Instructions/probuilder

RETURN

RETURN outputs the final value of a ProBuilder indicator so ProRealTime™ can plot it on the chart, with optional AS labels, COLOURED and STYLE settings.

Syntax

probuilder
RETURN expression

With display options and multiple values:

probuilder
RETURN expression1 COLOURED(R, G, B) AS "Label 1", expression2 AS "Label 2"

How it works

Every custom indicator ends with a RETURN statement. The expressions listed after RETURN become the curves the platform draws, one curve per expression, separated by commas. Execution of the script stops at RETURN, so it is conventionally the last line, and any code after it never runs.

Each returned expression accepts optional display clauses. AS "name" labels the curve in the legend and value table. COLOURED(R, G, B) fixes the line color from RGB components. STYLE controls the line type and thickness. These clauses attach per value, so a two-line indicator can style each curve independently.

RETURN belongs to indicator code only. ProOrder and ProBacktest strategies do not plot values through RETURN, they use GRAPH and GRAPHONPRICE for inspection output, and a RETURN statement in strategy code is rejected. ProScreener uses the SCREENER instruction to emit its result column instead.

A bare RETURN with no expression is valid and plots nothing, which is useful when the script draws exclusively through drawing commands such as DRAWTEXT and only needs a termination point.

When one indicator invokes another through CALL, the values received on the calling side are exactly the expressions the called script listed after its own RETURN, in the same order. Designing the RETURN line of a reusable indicator therefore defines its public interface.

Examples

Example 1, Returning a styled RSI curve (Indicator)

probuilder
// 14-period RSI plotted in a custom color with a legend label
myIndicatorToDraw = RSI[14](close)
RETURN myIndicatorToDraw COLOURED(210,105,30) AS "my RSI"

The RSI value is computed, then RETURN plots it as a single curve with a fixed color and the label "my RSI".

Example 2, Returning two labelled curves (Indicator)

probuilder
// Plot a fast and a slow moving average together
fastMA = average[20](close)
slowMA = average[50](close)
RETURN fastMA COLOURED(0,150,0) AS "Fast 20", slowMA COLOURED(150,0,0) AS "Slow 50"

A comma-separated list after RETURN produces two independent curves, each with its own color and legend entry.

Example 3, Bare RETURN with drawing commands (Indicator)

probuilder
// Mark bullish engulfing bars, no curve needed
IF close > open AND close[1] < open[1] AND close > open[1] AND open < close[1] THEN
  DRAWARROWUP(barindex, low) COLOURED(0, 200, 0)
ENDIF
RETURN

The indicator communicates entirely through drawings, so RETURN carries no expression and simply terminates the script.

Common errors and gotchas

  • Code after RETURN never runs. RETURN stops execution, so statements below it are dead code. Multiple conditional RETURN lines also mean only the first one reached takes effect on a given bar.
  • Not valid in strategies. ProOrder and ProBacktest code cannot use RETURN. Use GRAPH or GRAPHONPRICE there, and the SCREENER instruction in ProScreener.
  • Missing labels on multi-value output. Several returned expressions without AS labels are hard to tell apart in the legend and value table. Label every curve.
  • Options in the wrong order. Display clauses attach to the value they follow. Writing RETURN a, b COLOURED(255,0,0) colors only b, not both curves.
  • AS, labels a returned value in the legend and value table.
  • COLOURED, sets the color of a returned curve.
  • STYLE, sets line type and thickness of a returned curve.
  • DRAWTEXT, draws text on the chart independently of RETURN.
  • CALL, invokes another indicator and receives its returned values.
  • IF, conditional logic that prepares the value RETURN outputs.
  • GRAPH, strategy-side counterpart for plotting debug values.
  • SCREENER, screener-side counterpart that emits the result column.