# Resolution

## Overview

**Resolution** or time interval is a time period of a single bar.
Changing the resolution allows users to switch between different levels of detail, from short-term intraday moves to long-term historical trends.

This article explains how to:

- Specify resolutions in the correct format.
- Set up the default resolution for the chart.
- Change the resolution in the UI or using the API.
- Adjust additional settings, such as disabling resolution changes or enabling custom resolutions.

For more information on how to configure resolutions on the datafeed side, see [Configure resolutions in datafeed](https://charting-library-docs.xstaging.tv/latest/connecting_data/time-and-sessions/configure-datafeed-resolutions.md).

## Resolution format

The library supports resolutions in seconds, minutes, hours, days, weeks, months, years, and ticks.

A resolution value should have the [`ResolutionString`](../api/modules/Datafeed.md#resolutionstring) type.
The table below describes how to specify different resolution values. In these values, `x` represents a number of units.

 Resolution | Format | Example
---------|----------|---------
Ticks | `xT` | `1T` — one tick, `5T` — five ticks, `100T` — one hundred ticks
Seconds | `xS` | `1S` — one second, `2S` — two seconds, `100S` — one hundred seconds
Minutes | `x` | `1` — one minute, `2` — two minutes, `100` — one hundred minutes
Hours | `x` minutes | `60` — one hour, `120` — two hours, `240` — four hours
Days | `xD` | `1D` — one day, `2D` — two days, `100D` — one hundred days
Weeks | `xW` | `1W` — one week, `2W` — two weeks, `100W` — one hundred weeks
Months | `xM` | `1M` — one month, `2M` — two months, `100M` — one hundred months
Years | `xM` months | `12M` — one year, `24M` — two years, `48M` — four years

You can also omit the number of units if it is equal to `1`. For example, you can use `D` instead of `1D` and `W` instead of `1W`.

## Set up resolution on the chart

The resolution is [initialized](#default-resolution) in the Widget Constructor and can be changed [in the UI](#in-ui) or [using the API](#using-api).

To get the current resolution, use the [`resolution`](../api/interfaces/Charting_Library.IChartWidgetApi.md#resolution) method.

```javascript
widget.onChartReady(() => {
    widget.activeChart().resolution();
});
```

### Default resolution

You can specify the default resolution using the [`interval`](../api/interfaces/Charting_Library.ChartingLibraryWidgetOptions.md#interval) property in the [Widget Constructor](https://charting-library-docs.xstaging.tv/latest/configuration/Widget-Constructor.md).

```javascript
new TradingView.widget({
    // ...
    interval: '1D',
});
```

### In UI

Users can change the resolution in the following ways:

- Use the _Resolution_ button on the top toolbar.

- Use the _Resolution_ button in the [_Legend_].

- Press any digit key or the , (comma) key.

To disable any of the methods above, refer to [Disable resolution changing](#disable-resolution-changing).

### Using API

You can use the [`setResolution`](../api/interfaces/Charting_Library.IChartWidgetApi.md#setresolution) method to change the resolution on the fly.

```javascript
widget.onChartReady(() => {
    widget.activeChart().setResolution('2M');
});
```

:::caution

In the UI, users can enter values like `2h` to specify a number of hours. However, you should specify hour resolutions in minutes, for example `120`, if you change the resolution using the API.

:::

## Additional settings

You can use [featuresets](https://charting-library-docs.xstaging.tv/latest/customization/Featuresets.md) to adjust resolution settings.

### Disable resolution rebuilding

The library aligns bars to the nearest expected bar position. For example, if [`session`](../api/interfaces/Charting_Library.LibrarySymbolInfo.md#session) is `0915-1530` and the chart shows a 5-minute resolution, the library expects the following bar timestamps: `[09:15, 09:20, 09:25, ...]`.
If your datafeed provides a bar with the `09:17` timestamp, the library changes this timestamp to `09:15`.
You can use the [`disable_resolution_rebuild`] featureset to display bars exactly as your datafeed provides.

:::info

If you enable the `disable_resolution_rebuild` featureset, the library cannot build resolutions that your datafeed does not explicitly provide. For example, the library cannot build a 5-minute resolution from 1-minute data.

:::

### Enable custom resolutions

Users can add their custom resolutions in the UI. To allow this feature, do the following:

- Enable the [`custom_resolutions`](../customization/Featuresets.md#custom_resolutions) featureset that displays
the corresponding button in the UI.

- Specify the list of resolutions that the certain symbol supports in the [`LibrarySymbolInfo.supported_resolutions`](../api/interfaces/Charting_Library.LibrarySymbolInfo.md#supported_resolutions) property. Users can add any resolution, but it will be disabled if it is not included in this list.

Note that you do not need to provide data for every resolution you want to support. The library can [build additional resolutions](https://charting-library-docs.xstaging.tv/latest/connecting_data/time-and-sessions/configure-datafeed-resolutions.md#additional-resolutions) from the available data. Make sure to specify a list of resolutions that your datafeed provides in the `*_multipliers` properties ([`seconds_multipliers`], [`daily_multipliers`], etc.).

#### Example

The default list of resolutions for the chart is specified in the [`DatafeedConfiguration.supported_resolutions`](../api/interfaces/Charting_Library.DatafeedConfiguration.md#supported_resolutions) property. It includes 1-minute, 2-minute, and 5-minute resolutions. These resolutions will be displayed for all symbols, even if a certain symbol does not support them.

```javascript
// DatafeedConfiguration object
{
    //...
    supported_resolutions = ["1", "2", "5"]; // Resolutions displayed in the list by default
};
```

AAPL supports 1-minute, 5-minute, and 6-minute resolutions, as specified in `LibrarySymbolInfo.supported_resolutions`.
The symbol does not support 2-minute resolution, therefore, it will be disabled in the UI. The 6-minute resolution is not displayed by default, but it will be available if users add it manually.

```javascript
// LibrarySymbolInfo object for AAPL
{
    "has_intraday": true,
    "supported_resolutions": ["1", "5", "6"], // Resolutions that the symbol supports
    "intraday_multipliers": ["1"], // Resolutions that your datafeed provides
    //...
}
```

If users enter an unsupported resolution such as 10 minutes, it will still appear in the list but will be disabled.

### Disable resolution changing

You can use the [`header_resolutions`](../customization/Featuresets.md#header_resolutions) featureset to remove the _Resolution_ button from the top toolbar.

![Remove resolution button](/img/no-resolution-button.png)

To disable resolution changing in the [_Legend_], use the [`legend_inplace_edit`](../customization/Featuresets.md#legend_inplace_edit) featureset.
If you want to completely remove the _Resolution_ button from the _Legend_, use the [`hide_resolution_in_legend`](../customization/Featuresets.md#hide_resolution_in_legend) featureset.

![Remove resolution from Legend](/img/no-resolution-legend.png)

To disable the _Resolution_ shortcut, use the [`show_interval_dialog_on_key_press`](../customization/Featuresets.md#show_interval_dialog_on_key_press) featureset.

[_Legend_]: https://charting-library-docs.xstaging.tv/latest/ui_elements/Legend.md
[`disable_resolution_rebuild`]: https://charting-library-docs.xstaging.tv/latest/customization/Featuresets.md#disable_resolution_rebuild
[`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

---

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