3.9.4Loading an indicator onto a chart

You can use ChartChange() to load a new indicator onto a chart. The extra settings in the call to ChartChange() are as follows:

Property

Description

indicator

The class name of an indicator in the FXB.ta library, such as "MACD" or "RSI". However, in addition to indicators from the FXB.ta library, it is also possible to load some extra indicators, as described below.

indicatorSettings:{}

The parameters for the indicator, as specified when creating an instance of the FXB.ta class. You only need to specify parameters which you want to change from the defaults.

For example, you can add MACD to a chart as follows. Note that the maType for the calculation is not specified in this example, and defaults to EMA (maType = 1).

Framework.ChartChange({

mode: "active", // or "all", or "single" plus a .chartId value

command: "load-indicator",

indicator: "MACD",

indicatorSettings: {

fast: 12,

slow: 26,

signal: 9

}

});

Similarly, you can add the Average True Range indicator to a chart:

Framework.ChartChange({

mode: "active", // or "all", or "single" plus a .chartId value

command: "load-indicator",

indicator: "ATR",

indicatorSettings: {

// The period defaults to 14 if not specified

}

});

Or, an exponential moving average:

Framework.ChartChange({

mode: "active", // or "all", or "single" plus a .chartId value

command: "load-indicator",

indicator: "EMA",

indicatorSettings: {

period: 20

}

});

In addition to indicators from the FXB.ta library, it is also possible to use command: "load-indicator" to load some special further types of indicators. For example:

Framework.ChartChange({

mode: "active", // or "all", or "single" plus a .chartId value

command: "load-indicator",

indicator: "PeriodSeparator", // Visual period-separator markers

indicatorSettings: {

timeframe: 86400 // … on a daily (D1) basis

}

});

The special extra indicators which can be loaded using load-indicator are as follows:

indicator value

Description

indicatorSettings:{}

Calendar

Platform's calendar indicator, showing markers for calendar events

(none)

TradeHistory

Platform's trade-history indicator, showing markers for historic trades

(none)

PeriodSeparator

Period-separator markers

Can optionally provide a timeframe for the separators. Defaults to 86400 (D1) if omitted.

Fractals

Displays "fractal" markers

Can optionally provide a period specifying the required number of bars either side of the high/low fractal. Defaults to 2 (bars) if omitted.

Comparison

Overlays a second market on the chart, as a comparison line

Requires an instrumentId, such as "GBP/USD", specifying the additional market to display

PivotPoints

Displays pivot points

Can optionally provide a pivotType specifying the type of pivot-point calculation. Defaults to "classic". Other supported values, for common pivot types, are "woodie", "fibonacci", and "camarilla".

UDI

Loads a User Defined Indicator

Requires either a url, to fetch the UDI code from a remote location, or a script value, to load the UDI from inline script. Can also contain asUDIX:true to load the UDI with Framework access. Note: UDIs loaded in this way are never allowed to place trades.