Skip to main content

Indicator placement

View as Markdown

When an indicator is added to the chart, the library chooses the pane and price scale to place it on. This article describes the default placement rules and how to change them.

Default placement​

Indicators are divided into two groups depending on the range of values they return.

  • Price indicators return values in the same range as their source. For example, Moving Average and Bollinger Bands return prices. The library places such indicators on the pane of their source and attaches them to the same price scale.
  • Non-price indicators return values in a different range. For example, Stochastic always returns values from 0 to 100. The library places such indicators on a new pane and attaches them to a new price scale.

The source of an indicator is the main series, unless the indicator is applied to another indicator.

For custom indicators, the group is defined by the is_price_study property of the metainfo object.

Change the pane​

To place a non-price indicator on the pane of its source, pass true to the forceOverlay parameter of the createStudy method.

widget.activeChart().createStudy('Stochastic', true);
info

forceOverlay affects non-price indicators only and does not change the price scale. There is no way to place a price indicator on a separate pane at creation time. Instead, add the indicator first and then move it to another pane.

Change the price scale​

To attach an indicator to a certain price scale, specify the priceScale property in the options parameter of createStudy. The library looks for a suitable scale within the pane where the indicator is placed.

ValueDescription
new-rightAttaches the indicator to a new right price scale.
new-leftAttaches the indicator to a new left price scale.
no-scaleAdds the indicator in the No Scale mode without attaching it to a price scale.
as-seriesAttaches the indicator to the price scale of the main series. If the pane does not contain the main series, the indicator is attached to a new price scale instead.

The code sample below adds a Price Channel indicator to the pane with the main series and attaches it to a new left price scale.

widget.activeChart().createStudy('Price Channel', true, false, undefined, undefined, { priceScale: 'new-left' });
info

A pane can contain up to eight price scales. If the limit is reached, new-right and new-left add the indicator in the No Scale mode.

Move an indicator to another pane​

Users can move an indicator using the Move to option in its context menu. The option offers the Existing pane above, New pane above, Existing pane below, and New pane below commands.

To do the same programmatically, get the indicator with getStudyById and call the corresponding IStudyApi method.

widget.activeChart().getStudyById(studyId).unmergeDown();

To change the price scale of an existing indicator, use changePriceScale. The method accepts the same values as the priceScale property, as well as the ID of another indicator whose price scale should be used.

To interact with the panes themselves, use the getPanes method. It returns an array of IPaneApi objects that allow you to change the pane height and position, and to collapse or maximize the pane.

Custom indicator placement​

The default placement of a custom indicator is defined in its metainfo object.

PropertyDescription
is_price_studyWhether the indicator is a price indicator and therefore appears on the pane of its source.
linkedToSeriesWhether the indicator always uses the price scale of the main series. If true, the Move to option is hidden in the UI.
priceScaleThe price scale to attach the indicator to. Refer to StudyTargetPriceScale for the available values.
overlayScaleMarginsThe share of the series pane the indicator occupies when it is displayed there without a visible price scale, as the built-in Volume indicator is.