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.
Sintassi
RETURN expressionCon opzioni di visualizzazione e più valori:
RETURN expression1 COLOURED(R, G, B) AS "Label 1", expression2 AS "Label 2"Come funziona
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.
Ogni espressione restituita accetta clausole di visualizzazione opzionali. AS "name" etichetta la curva nella legenda e nella tabella dei valori. COLOURED(R, G, B) fissa il colore della linea dalle componenti RGB. STYLE controlla il tipo e lo spessore della linea. Queste clausole si applicano per singolo valore, quindi un indicatore a due linee può stilizzare ogni curva in modo indipendente.
RETURN belongs to indicator code only. ProOrder and ProBacktest strategies do not plot values through RETURN, they use GRAPH e GRAPHONPRICE for inspection output, and a RETURN statement in strategy code is rejected. ProScreener uses the SCREENER istruzione per emettere invece la sua colonna di risultato.
Un semplice RETURN senza espressione è valido e non traccia nulla, cosa utile quando lo script disegna esclusivamente tramite comandi di disegno come DRAWTEXT e richiede solo un punto di terminazione.
Quando un indicatore ne richiama un altro tramite 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.
Esempi
Esempio 1, Restituire una curva RSI con stile (Indicatore)
// 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".
Esempio 2, Restituire due curve etichettate (Indicatore)
// 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.
Errori e insidie comuni
- 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.
- Non valido nelle strategie. ProOrder and ProBacktest code cannot use RETURN. Use
GRAPHoGRAPHONPRICElì, e ilSCREENERistruzione in ProScreener. - Etichette mancanti su output a più valori. Più espressioni restituite senza
ASle etichette sono difficili da distinguere nella legenda e nella tabella dei valori. Etichetta ogni curva. - Opzioni nell'ordine sbagliato. Le clausole di visualizzazione si applicano al valore che seguono. Scrivere
RETURN a, b COLOURED(255,0,0)colora solob, non entrambe le curve.
Istruzioni correlate
AS, etichetta un valore restituito nella legenda e nella tabella dei valori.COLOURED, imposta il colore di una curva restituita.STYLE, imposta il tipo e lo spessore della linea di una curva restituita.DRAWTEXT, draws text on the chart independently of RETURN.CALL, richiama un altro indicatore e riceve i valori che restituisce.IF, conditional logic that prepares the value RETURN outputs.GRAPH, controparte lato strategia per tracciare valori di debug.SCREENER, controparte lato screener che emette la colonna del risultato.