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.
Sintaxis
RETURN expressionCon opciones de visualización y varios valores:
RETURN expression1 COLOURED(R, G, B) AS "Label 1", expression2 AS "Label 2"Cómo funciona
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.
Cada expresión devuelta acepta cláusulas de visualización opcionales. AS "name" etiqueta la curva en la leyenda y en la tabla de valores. COLOURED(R, G, B) fija el color de la línea a partir de componentes RGB. STYLE controla el tipo y el grosor de la línea. Estas cláusulas se aplican por valor, así que un indicador de dos líneas puede dar estilo a cada curva de forma independiente.
RETURN belongs to indicator code only. ProOrder and ProBacktest strategies do not plot values through RETURN, they use GRAPH y GRAPHONPRICE for inspection output, and a RETURN statement in strategy code is rejected. ProScreener uses the SCREENER instrucción para que emita en su lugar su columna de resultado.
Un simple RETURN sin expresión es válido y no representa nada, lo que resulta útil cuando el script dibuja exclusivamente mediante comandos de dibujo como DRAWTEXT y solo necesita un punto de terminación.
Cuando un indicador invoca a otro mediante 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.
Ejemplos
Ejemplo 1, Devolver una curva RSI con estilo (Indicador)
// 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".
Ejemplo 2, Devolver dos curvas etiquetadas (Indicador)
// 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)
// 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
RETURNThe indicator communicates entirely through drawings, so RETURN carries no expression and simply terminates the script.
Errores y trampas habituales
- 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.
- No válido en estrategias. ProOrder and ProBacktest code cannot use RETURN. Use
GRAPHoGRAPHONPRICEahí, y elSCREENERinstrucción en ProScreener. - Faltan etiquetas en una salida de varios valores. Varias expresiones devueltas sin
ASlas etiquetas son difíciles de distinguir en la leyenda y en la tabla de valores. Etiqueta cada curva. - Opciones en el orden incorrecto. Las cláusulas de visualización se aplican al valor al que siguen. Escribir
RETURN a, b COLOURED(255,0,0)colorea solob, no ambas curvas.
Instrucciones relacionadas
AS, etiqueta un valor devuelto en la leyenda y en la tabla de valores.COLOURED, define el color de una curva devuelta.STYLE, define el tipo y el grosor de línea de una curva devuelta.DRAWTEXT, draws text on the chart independently of RETURN.CALL, invoca otro indicador y recibe los valores que devuelve.IF, conditional logic that prepares the value RETURN outputs.GRAPH, equivalente del lado de la estrategia para dibujar valores de depuración.SCREENER, equivalente del lado del screener que emite la columna de resultados.