Signal scripts are used for generating numeric buy/sell trading signals based on the price, volume and open interest of an underlying symbol. Common use-cases include plotting them on a chart, displaying them as watchlist columns and using them to implement other scripts.


Setup


A Signal script can be added to a chart using the chart's Signals Window and it can be added to a watchlist using the watchlist's Script Columns Window. To use a Signal script from a Trading Strategy script (or any other supported script) please see our sample Trading Strategy scripts that ship with the platform.


Functions


Name

Description

OnInitialize()

This function accepts the user parameters for the script and is called when a new signal instance is created.

One of the parameters accepted by it must be that of a symbol or another script that is based on a symbol (drawing, indicator, pattern or signal). This symbol will be used as the underlying symbol for the signal.


The parameter values can be specified from the user interface (UI) or from another script, depending on usage.

double OnBarUpdate()

This function is called to calculate the signal for the latest bar.


Function Details


OnInitialize()

This function accepts the user parameters for the script and is called when a new signal instance is created.

One of the parameters accepted by it must be that of a symbol or another script that is based on a symbol (drawing, indicator, pattern or signal). This symbol will be used as the underlying symbol for the signal.


The parameter values can be specified from the user interface (UI) or from another script, depending on usage.


double OnBarUpdate()

This function is called to calculate the signal for the latest bar.


Returns


A trading signal ranging from -100 (strong sell) to 100 (strong buy) for the latest bar.