Indicator functions are mostly used for building indicators and accessing indicator script instances. For performance reasons indicators should only be created from the OnInitialize function and never from the OnBarUpdate function or any other frequently called function.


Read more: Indicator Scripts


Sections


Functions

Function Details


Functions


Name

Description

IndicatorChartRegisterPen(byte, string, C_Color, C_DashStyle, int)

Registers a pen for the indicator so that it may be used for plotting indicator values on the chart. Note that this function should be called from the OnChartSetup function.

IndicatorChartRegisterPenRGB(byte, string, int[], C_DashStyle, int)

Registers a pen for the indicator so that it may be used for plotting indicator values on the chart. Note that this function should be called from the OnChartSetup function.

IndicatorChartSetColorZone(double, double, int[], int[], C_DashStyle, int)

Sets a color zone on the indicator chart panel between two specified values. Note that this function should be called from the OnChartSetup function.

IndicatorChartSetMultiValueNames

Set the names of the multi-value indicator series to be displayed on a chart. Note that this function should be called from the OnChartSetup function.

IndicatorChartSetNewPanel(bool)

Indicates whether the indicator should be plotted on a new chart panel or an existing one. Note that this function should be called from the OnChartSetup function.

IndicatorChartSetPlotStyle(C_PlotStyle)

Sets the default plot style of the indicator. Note that this function should be called from the OnChartSetup function.

IndicatorChartSetRange(double, double)

Sets the y-axis range for the chart panel displaying the indicator. Note that this function should be called from the OnChartSetup function.

IndicatorCreateSeries(int)

Creates a specified number of internal series as required by the indicator (Call from the OnInitialize function).

double[] IndicatorGetMultiValue

Gets the values of the underlying multi-value indicator at a specified bar.

double[] IndicatorGetMultiValue(Indicator, int)

Gets the values of the underlying multi-value indicator at a specified bar.

double IndicatorGetSeriesValue(int, int)

Gets a specified series value at a specified bar shift of a specified internal series.

IndicatorRemove(Indicator)

Removes a specified indicator from memory (not from a chart). Note that calling this function is rarely required since memory is automatically freed when the script shuts down.

IndicatorSetSeriesValue(int, int, double)

Sets a specified series value at a specified bar shift of a specified internal series.

Indicator IndicatorSetSymbol(Indicator, int)

Copies a specified indicator from the OnInitialize parameters and assign it a symbol. The function is required since the indicator parameters of the Multi-Symbol Trading Strategy do not have an underlying symbol assigned to them.

int IndicatorSymbolIndex(Indicator)

Gets the underlying symbol index of a specified indicator.

double IndicatorValue(Indicator, int)

Gets the indicator value of a specified indicator at a specified bar, which is equivalent to indicatorIdentifier[barShift].

int IndicatorValueCount()

Gets the number of indicator values set thus far, or the number of data bars processed thus far.


Function Details


IndicatorChartRegisterPen(byte index, string penName, C_Color color, C_DashStyle dashStyle, int thickness)

Registers a pen for the indicator so that it may be used for plotting indicator values on the chart. Note that this function should be called from the OnChartSetup function.


Parameters


Type

Identifier

Description

byte

index

The unique pen index that will identify it in the OnSelectPen function

string

penName

The unique pen name to display when using the indicator

C_Color

color

The color of the pen

C_DashStyle

dashStyle

The dash style to use for the pen (View Options)

int

thickness

The pen thickness


Scripts


Indicator


IndicatorChartRegisterPenRGB(byte index, string penName, int[] color, C_DashStyle dashStyle, int thickness)

Registers a pen for the indicator so that it may be used for plotting indicator values on the chart. Note that this function should be called from the OnChartSetup function.


Parameters


Type

Identifier

Description

byte

index

The unique pen index that will identify it in the OnSelectPen function

string

penName

The unique pen name to display when using the indicator

int[]

color

The RGB+Alpha color of the pen (R, G, B, Alpha)

C_DashStyle

dashStyle

The dash style to use for the pen (View Options)

int

thickness

The pen thickness


Scripts


Indicator


IndicatorChartSetColorZone(double bottomPrice, double topPrice, int[] backgroundColor, int[] strokeColor, C_DashStyle strokeStyle, int strokeThickness)

Sets a color zone on the indicator chart panel between two specified values. Note that this function should be called from the OnChartSetup function.


Parameters


Type

Identifier

Description

double

bottomPrice

The price that outlines the bottom of the color zone

double

topPrice

The price that outlines the top of the color zone

int[]

backgroundColor

The RGB+Alpha background color (R, G, B, Alpha)

int[]

strokeColor

The RGB+Alpha color of the stroke that outlines the color zone (R, G, B, Alpha)

C_DashStyle

strokeStyle

The style of the stroke that outlines the color zone (View Options)

int

strokeThickness

The thickness (in pixels) of the stroke that outlines the color zone


Scripts


Indicator


IndicatorChartSetMultiValueNames(string[] seriesNames)

Set the names of the multi-value indicator series to be displayed on a chart. Note that this function should be called from the OnChartSetup function.


Parameters


Type

Identifier

Description

string[]

seriesNames

The names of the multi-value indicator series.


Scripts


Indicator


IndicatorChartSetNewPanel(bool newChartPanel)

Indicates whether the indicator should be plotted on a new chart panel or an existing one. Note that this function should be called from the OnChartSetup function.


Parameters


Type

Identifier

Description

bool

newChartPanel

Indicates whether the indicator should be plotted on a new chart panel or an existing one


Scripts


Indicator


IndicatorChartSetPlotStyle(C_PlotStyle plotStyle)

Sets the default plot style of the indicator. Note that this function should be called from the OnChartSetup function.


Parameters


Type

Identifier

Description

C_PlotStyle

plotStyle

The plot style of the indicator (View Options)


Scripts


Indicator


IndicatorChartSetRange(double minValue, double maxValue)

Sets the y-axis range for the chart panel displaying the indicator. Note that this function should be called from the OnChartSetup function.


Parameters


Type

Identifier

Description

double

minValue

The minimum y-axis value for the chart panel displaying the indicator

double

maxValue

The maximum y-axis value for the chart panel displaying the indicator


Scripts


Indicator


IndicatorCreateSeries(int numberOfSeries)

Creates a specified number of internal series as required by the indicator (Call from the OnInitialize function).


Parameters


Type

Identifier

Description

int

numberOfSeries

The number of internal series required by the indicator (the number of series to create)


Scripts


Indicator


double[] IndicatorGetMultiValue(int barShift)

Gets the values of the underlying multi-value indicator at a specified bar.


Returns


The values of the underlying multi-value indicator at a specified bar.


Parameters


Type

Identifier

Description

int

barShift

The shift relative to the last bar, such that 0 is the latest bar, 1 is the bar preceding it, etc.


Scripts


Indicator


double[] IndicatorGetMultiValue(indicator Indicator, int barShift)

Gets the values of the specified multi-value indicator at a specified bar.


Returns


The values of the specified multi-value indicator at a specified bar.


Parameters


Type

Identifier

Description

Indicator

indicator

The indicator from which to get the values

int

barShift

The shift relative to the last bar, such that 0 is the latest bar, 1 is the bar preceding it, etc.


Scripts


TradeManagementStrategy, Drawing, Indicator, MultiSymbolTradingStrategy, Pattern, PositionSizing, Signal, TradingStrategy


double IndicatorGetSeriesValue(int seriesIndex, int barShift)

Gets a specified series value at a specified bar shift of a specified internal series.


Returns


The specified series value at the specified bar shift of the specified internal series.


Parameters


Type

Identifier

Description

int

seriesIndex

The internal series index (from 0 to the number specified in IndicatorCreateSeries - 1)

int

barShift

The shift relative to the last bar, such that 0 is the latest bar, 1 is the bar preceding it, etc.


Scripts


Indicator


IndicatorRemove(Indicator indicator)

Removes a specified indicator from memory (not from a chart). Note that calling this function is rarely required since memory is automatically freed when the script shuts down.


Parameters


Type

Identifier

Description

Indicator

indicator

The indicator to remove


Scripts


TradeManagementStrategy, Drawing, Indicator, MultiSymbolTradingStrategy, Pattern, PositionSizing, Signal, TradingStrategy


IndicatorSetSeriesValue(int seriesIndex, int barShift, double value)

Sets a specified series value at a specified bar shift of a specified internal series.


Parameters


Type

Identifier

Description

int

seriesIndex

The internal series index (from 0 to the number specified in IndicatorCreateSeries - 1)

int

barShift

The shift relative to the last bar, such that 0 is the latest bar, 1 is the bar preceding it, etc.

double

value

The series value


Scripts


Indicator


Indicator IndicatorSetSymbol(Indicator indicator, int symbolIndex)

Copies a specified indicator from the OnInitialize parameters and assign it a symbol. The function is required since the indicator parameters of the Multi-Symbol Trading Strategy do not have an underlying symbol assigned to them.


Returns


A copy of the specified indicator over the specified symbol.


Parameters


Type

Identifier

Description

Indicator

indicator

The indicator to copy

int

symbolIndex

The symbol index to assign the new indicator


Scripts


MultiSymbolTradingStrategy


int IndicatorSymbolIndex(Indicator indicator)

Gets the underlying symbol index of a specified indicator.


Returns


The underlying symbol index of the specified indicator.


Parameters


Type

Identifier

Description

Indicator

indicator

The indicator


Scripts


TradeManagementStrategy, Drawing, Indicator, MultiSymbolTradingStrategy, Pattern, PositionSizing, Signal, TradingStrategy


double IndicatorValue(Indicator indicator, int barShift)

Gets the indicator value of a specified indicator at a specified bar, which is equivalent to indicatorIdentifier[barShift].


Returns


The indicator value of the specified indicator at the specified bar.


Parameters


Type

Identifier

Description

Indicator

indicator

The indicator from which to get the value

int

barShift

The shift relative to the last bar, such that 0 is the latest bar, 1 is the bar preceding it, etc.


Scripts


TradeManagementStrategy, Drawing, Indicator, MultiSymbolTradingStrategy, Pattern, PositionSizing, Signal, TradingStrategy


int IndicatorValueCount()

Gets the number of indicator values set thus far, or the number of data bars processed thus far.


Returns


The number of indicator values set thus far, or the number of data bars processed thus far.


Scripts


Indicator