# Configure resolutions in datafeed

## Overview

**Resolutions** define the time interval of a single bar (for example, 1 minute, 1 day, or 1 month) on a chart.
While the [Resolution] article explains how you can manage resolutions in the UI, this article focuses on the datafeed side.

To ensure that charts display data correctly for each resolution, you need to configure your [datafeed].
This includes:

1. Declaring which resolutions are supported globally and per symbol.
2. Enabling special resolutions such as seconds or ticks.
3. Implementing the data request logic for each resolution in the [`getBars`] method.

The following sections provide **step-by-step** instructions for configuring resolutions in your datafeed.

## 1. Specify supported resolutions

To enable any resolution, specify the following properties:

- [`DatafeedConfiguration.supported_resolutions`](../../api/interfaces/Charting_Library.DatafeedConfiguration.md#supported_resolutions) contains all resolutions that the chart should support.
- [`LibrarySymbolInfo.supported_resolutions`](../../api/interfaces/Charting_Library.LibrarySymbolInfo.md#supported_resolutions) contains all resolutions that a certain symbol should support.

The resolutions should be listed in a specific [format](https://charting-library-docs.xstaging.tv/latest/ui_elements/Resolution.md#resolution-format). For example, `["1", "15", "240", "D", "6M"]` stands for 1 minute, 15 minutes, 4 hours, 1 day, and 6 months. If the certain symbol does not support some chart resolutions, they are disabled for this symbol in the UI.

![Supported resolutions](/img/symbology_supported_resolutions.png)

If a user switches to another symbol, that does not support the selected resolution, the library changes the resolution to the first available one for this symbol.

### Additional resolutions

The library can combine smaller intervals into larger ones to build new resolutions. For instance, it can build 2-minute bars from 1-minute bars.
Therefore, you can enable resolutions that your datafeed does not explicitly provide. To do this, add these resolutions to the `supported_resolutions` arrays mentioned [above](#1-specify-supported-resolutions).

If you want to [disable resolution rebuilding](https://charting-library-docs.xstaging.tv/latest/ui_elements/Resolution.md#disable-resolution-rebuilding), use the [`disable_resolution_rebuild`] featureset.

:::caution

The library **cannot** build the following resolutions:

- daily, weekly, or monthly resolutions using intraday data
- resolutions higher than seconds using tick data

:::

## 2. Enable required resolutions

Follow the instructions below to enable the required resolutions.

### Resolution in seconds

To enable resolution in seconds, additionally configure the following properties:

- Enable the [`seconds_resolution`](../../customization/Featuresets.md#seconds_resolution) featureset. To do this, include `seconds_resolution` to the [`enabled_features`](../../api/interfaces/Charting_Library.ChartingLibraryWidgetOptions.md#enabled_features) array.
- Set [`has_seconds`](../../api/interfaces/Charting_Library.LibrarySymbolInfo.md#has_seconds) to `true`.
- Specify [`seconds_multipliers`] that contains the resolutions provided by the datafeed.

Additionally, if your datafeed supports tick data for a symbol, you can tell the library to build seconds bars from ticks. To do this, set [`build_seconds_from_ticks`](../../api/interfaces/Charting_Library.LibrarySymbolInfo.md#build_seconds_from_ticks) to `true`. Note that this feature is available in Trading Platform only.

### Resolution in minutes (intraday)

To enable intraday resolution (in minutes), additionally configure the following properties:

- Set [`has_intraday`](../../api/interfaces/Charting_Library.LibrarySymbolInfo.md#has_intraday) to `true`.
- Specify [`intraday_multipliers`](../../api/interfaces/Charting_Library.LibrarySymbolInfo.md#intraday_multipliers) that contains the resolutions that the datafeed provides.

### Resolution in days

To enable resolution in days, additionally configure the following properties:

- Set [`has_daily`](../../api/interfaces/Charting_Library.LibrarySymbolInfo.md#has_daily) to `true`.
- Specify [`daily_multipliers`] that contains the resolutions that the datafeed provides.

### Resolution in weeks / months

To enable resolution in weeks or months, additionally configure the following properties:

- Set [`has_weekly_and_monthly`](../../api/interfaces/Charting_Library.LibrarySymbolInfo.md#has_weekly_and_monthly) to `true`.
- Specify [`weekly_multipliers`](../../api/interfaces/Charting_Library.LibrarySymbolInfo.md#weekly_multipliers) or [`monthly_multipliers`](../../api/interfaces/Charting_Library.LibrarySymbolInfo.md#monthly_multipliers) that contains the resolutions that the datafeed provides.

### Resolution in ticks

To enable resolution in ticks, additionally configure the following properties:

- Enable the [`tick_resolution`](../../customization/Featuresets.md#tick_resolution) featureset. To do this, include `tick_resolution` to the [`enabled_features`](../../api/interfaces/Charting_Library.ChartingLibraryWidgetOptions.md#enabled_features) array.
- Set [`has_ticks`](../../api/interfaces/Charting_Library.LibrarySymbolInfo.md#has_ticks) to `true`.

Additionally, you can tell the library to build seconds bars from ticks. To do this, set [`build_seconds_from_ticks`](../../api/interfaces/Charting_Library.LibrarySymbolInfo.md#build_seconds_from_ticks) to `true`. Note that this feature is available in Trading Platform only.

## 3. Implement method in datafeed

The library requests data from the datafeed based on the current resolution selected on the chart. All resolutions that your datafeed explicitly supports should be listed in the `*_multipliers` properties ([`seconds_multipliers`], [`daily_multipliers`], etc.) and implemented in the [`getBars`] method.

## Example

Consider the following example. The datafeed has 1-minute and 2-minute bars. Also, you would like to support a 5-minute resolution. In this case, you should configure the [`LibrarySymbolInfo`](../../api/interfaces/Charting_Library.LibrarySymbolInfo.md) properties as follows:

```js
//...
"has_intraday": true,
"supported_resolutions": ["1", "2", "5"],
"intraday_multipliers": ["1", "2"], // The library can request 1-minute and 2-minute bars, and will build 5-minute bars from 1-minute data
//...
```

The example of the `getBars` implementation is demonstrated below:

```js
getBars(symbolInfo, resolution, periodParams, onHistoryCallback, onErrorCallback) {
    if (resolution === '1') {
        const bars = getBarsFor1MinuteResolution(periodParams);
        onHistoryCallback(bars);
        ​
        return;
    }
    ​
    if (resolution === '2') {
        const bars = getBarsFor2MinuteResolution(periodParams);
        onHistoryCallback(bars);
        ​
        return;
    }

    //...
}

function getBarsFor1MinuteResolution(periodParams) {
    // Your custom logic
}

function getBarsFor2MinuteResolution(periodParams) {
    // Your custom logic
}
```

[`getBars`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.IDatafeedChartApi#getbars
[datafeed]: https://charting-library-docs.xstaging.tv/latest/connecting_data/datafeed-api.md
[Resolution]: https://charting-library-docs.xstaging.tv/latest/ui_elements/Resolution.md
[`seconds_multipliers`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.LibrarySymbolInfo#seconds_multipliers
[`daily_multipliers`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.LibrarySymbolInfo#daily_multipliers
[`disable_resolution_rebuild`]: https://charting-library-docs.xstaging.tv/latest/customization/Featuresets.md#disable_resolution_rebuild

---

## 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)
