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
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)
// 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)
// 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)
// 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,
ASdoes no comparison and returns no boolean. It only names output. For logic, useAND,OR,NOT, orXOR. - Quotes are required. The label after
ASmust be a string in double quotes, such asAS "Signal". Leaving out the quotes raises a syntax error. - Labels the value, not the variable.
ASrenames the output for display. It does not create or rename a variable you can reference later in the code. - Placement.
ASbelongs with the value being returned or listed, directly after the expression it labels, not on its own line.
