Operators/probuilder · probacktest · proorder · proscreener

AS

AS in ProBuilder labels a returned value or screener column with a custom name. Covers RETURN AS and SCREENER output naming with worked examples.

Syntax

probuilder
RETURN expression AS "Custom Name"

How it works

AS attaches a text label to a value on output. In an indicator it names the line drawn on the chart, which makes a script with several returned series easier to read. In a ProScreener it names a column in the results table. The name must be a string in double quotes.

AS does not change the value it labels and it plays no part in logic. It simply controls how the output is presented. It appears next to the value being returned, whether that is in a RETURN statement or in the value list of a SCREENER.

Examples

Example 1, Naming a plotted line (Indicator)

probuilder
// Plot a 14-period average and label it on the chart
MAVariable = Average[14](close)
RETURN MAVariable AS "My Moving Average"

This is the pattern from the official reference. The average is drawn on the chart under the label "My Moving Average" rather than an anonymous line.

Example 2, Naming several returned series (Indicator)

probuilder
// Return two averages, each with its own label
fast = Average[20](close)
slow = Average[50](close)
RETURN fast AS "Fast MA", slow AS "Slow MA"

Each returned value carries its own label, so the two lines are easy to tell apart on a chart that plots both.

Example 3, Naming a screener column (ProScreener)

probuilder
// Uptrend filter, showing the distance above the average as a named column
avg = Average[200](close)
cond = close > avg
gap = close - avg
SCREENER[cond](gap AS "Above 200MA")

The screener returns matching instruments with a column titled "Above 200MA" holding the value of gap, which is clearer than an unlabeled figure.

Common errors and gotchas

  • Not a logical operator. Despite sitting in the Operators category, AS does no comparison and returns no boolean. It only names output. For logic, use AND, OR, NOT, or XOR.
  • Quotes are required. The label after AS must be a string in double quotes, such as AS "Signal". Leaving out the quotes raises a syntax error.
  • Labels the value, not the variable. AS renames the output for display. It does not create or rename a variable you can reference later in the code.
  • Placement. AS belongs with the value being returned or listed, directly after the expression it labels, not on its own line.
  • RETURN, outputs one or more values from an indicator, where AS labels them.
  • SCREENER, defines a screener whose output columns AS can name.
  • GRAPH, plots an additional value that can also carry a label.
  • IF, AND, OR, the logic that decides what to return, distinct from labeling it.