Skip to main content
Version: v27

Custom indicators

Advanced Charts and Trading Platform support more than 100 indicators. You can also create your custom indicators in JavaScript using the library's API. The API allows you to create a variety of indicators using different plot types, styles, colors, and mathematical functions.

Users can add a custom indicator to the chart and change some indicator parameters using the Indicators and Settings dialog in the UI, respectively. However, users cannot create their own indicators or change the code of the existing ones.

info

Pine Script® is not supported in the libraries.

Add indicators

To add custom indicators to the library, specify a function that returns a Promise object with an array of custom indicator objects. Assign this function to the custom_indicators_getter property in the Widget Constructor.

custom_indicators_getter: function(PineJS) {
return Promise.resolve([
// Indicator objects
{
// ...
},
{
// ...
},
]);
},

Indicator object

A custom indicator is an instance of CustomIndicator that contains the following fields:

  • name: an indicator's internal name that is not visible in the UI. This name should be unique.
  • metainfo: the field that describes how the indicator looks like. This field defines the plot types that represent the indicator and contains information, such as an indicator's name, description, style, color, and more. Refer to the Metainfo article for more information.
  • constructor: the field that contains functions init() and main(). You should specify data calculations in these functions. Refer to Constructor for more information.
custom_indicators_getter: function(PineJS) {
return Promise.resolve([
{
// Indicator object
name: 'Custom indicator name',
metainfo: {
// ...
},
constructor: function() {
// ...
}
}
]);
},

Examples

Follow the links below to explore some implementation examples of custom indicators.