# Indicator placement

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.

```js
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](#move-an-indicator-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.

| Value | Description |
| --- | --- |
| `new-right` | Attaches the indicator to a new right price scale. |
| `new-left` | Attaches the indicator to a new left price scale. |
| `no-scale` | Adds the indicator in the _No Scale_ mode without attaching it to a price scale. |
| `as-series` | Attaches 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.

```js
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.

- [`mergeUp`] and [`mergeDown`] move the indicator to the existing pane above or below.
- [`unmergeUp`] and [`unmergeDown`] move the indicator to a new pane above or below.

```js
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][custom indicators] is defined in its [metainfo] object.

| Property | Description |
| --- | --- |
| [`is_price_study`] | Whether the indicator is a price indicator and therefore appears on the pane of its source. |
| [`linkedToSeries`] | Whether the indicator always uses the price scale of the main series. If `true`, the _Move to_ option is hidden in the UI. |
| [`priceScale`][metainfo price scale] | The price scale to attach the indicator to. Refer to [`StudyTargetPriceScale`] for the available values. |
| [`overlayScaleMargins`] | The 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. |

[`changePriceScale`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.IStudyApi#changepricescale
[`createStudy`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.IChartWidgetApi#createstudy
[`getPanes`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.IChartWidgetApi#getpanes
[`getStudyById`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.IChartWidgetApi#getstudybyid
[`IPaneApi`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.IPaneApi
[`IStudyApi`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.IStudyApi
[`is_price_study`]: https://charting-library-docs.xstaging.tv/latest/custom_studies/metainfo.md#is_price_study
[`linkedToSeries`]: https://charting-library-docs.xstaging.tv/latest/custom_studies/metainfo.md#linkedtoseries
[`overlayScaleMargins`]: https://charting-library-docs.xstaging.tv/latest/custom_studies/metainfo.md#overlayscalemargins
[`mergeDown`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.IStudyApi#mergedown
[`mergeUp`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.IStudyApi#mergeup
[`priceScale`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.CreateStudyOptions#pricescale
[`StudyTargetPriceScale`]: https://charting-library-docs.xstaging.tv/latest/api/enums/Charting_Library.StudyTargetPriceScale
[`unmergeDown`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.IStudyApi#unmergedown
[`unmergeUp`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.IStudyApi#unmergeup

[custom indicators]: https://charting-library-docs.xstaging.tv/latest/custom_studies.md
[indicator]: https://charting-library-docs.xstaging.tv/latest/ui_elements/indicators.md
[metainfo]: https://charting-library-docs.xstaging.tv/latest/custom_studies/metainfo.md
[metainfo price scale]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.RawStudyMetaInfo#pricescale
[pane]: https://charting-library-docs.xstaging.tv/latest/resources/glossary.md#pane
[price scale]: https://charting-library-docs.xstaging.tv/latest/ui_elements/Price-Scale.md
[series]: https://charting-library-docs.xstaging.tv/latest/resources/glossary.md#series

---

## Sitemap

- [All documentation pages](https://charting-library-docs.xstaging.tv/llms.txt)
- [Full page map with headings](https://charting-library-docs.xstaging.tv/docs_map.md)
