Topics like health, travel, finance, home, living, education and careers | Media Search Home

How to set a TradingView chart to the instrument"s ‘Exchange’ time zone?

Situation: You want to display the chart"s price bars in the time zone of the exchange at which the instrument trades. Or, alternatively, you added a script to the chart that uses the TradingView Pine variables and/or functions for time, and because of that need to set the chart"s time zone to ‘Exchange’.

IN THIS ARTICLE:

  • Solution: set the TradingView chart"s time zone by hand
  • Discussion: why the need to set a TradingView chart to ‘Exchange’?
# Solution: set the TradingView chart"s time zone by hand

To change the chart"s time zone, we first need to open the instrument settings window. One way to do so is by clicking on the gear icon, which displays to the right of the instrument"s name on the chart:

Configuring symbol settings in TradingViewConfiguring symbol settings in TradingView

In the settings window that this opens we select the ‘Timezone/Sessions’ tab. There we use the pull-down menu of the ‘Time Zone’ option to set the chart"s time zone to ‘Exchange’:

Setting a TradingView chartSetting a TradingView chart

Another way to adjust the chart"s time zone is with the clock that displays below the chart:

Time and time zone indicator below TradingView chartsTime and time zone indicator below TradingView charts

With a click on that chart time, a menu appears with the different time zone options for the chart"s price bars. Here we select the ‘Exchange’ option to have our chart use the instrument"s time zone:

Setting the chartSetting the chart# Discussion: why the need to set a TradingView chart to ‘Exchange’?

While any time zone can be used for our TradingView chart, the ‘Exchange’ time zone is by far the best setting. Why is that?

To standardise the behaviour of TradingView scripts, almost all built-in variables and functions for times and dates return values in the instrument"s exchange time zone (Pine Script Language Tutorial, n.d.; TradingView, n.d.). That means those functions and variables don"t take the chart"s current time zone setting into account, but simply use the instrument"s time zone.

While this doesn"t seem like a big deal, it can have a big consequence on how our script behaves. Let"s say we use the time() function to determine if a price bar falls within a specific session, and we want our strategy to only trade during a specific time range. Now when we use time() to check if the current bar falls within the 8:00 till 16:00 time range, but have our chart set to exchange time + 2 hours, then the 10:00 till 18:00 are highlighted by our script as belonging to that trading session.

When something like that happens, we can get the impression that either our code or TradingView has some bug while in fact it"s simply due to not setting the chart"s time zone to ‘Exchange’. (See the impact of different time zones on scripts to learn more about the relation between the time zone setting and script behaviour.)

Now to prevent differences between the time displayed on the chart the values that the script calculates with, we best set our chart"s time zone to ‘Exchange’.

It"s often easier to just keep the chart"s time zone set to ‘Exchange’. That way when you add another script to the chart, you don"t need to wonder whether that particular script uses one of the functions or variables that work with the instrument"s time zone. (For a list of those code elements, see which TradingView functions and variables return ‘Exchange’ time?).

For more on why the time zone setting matters and how it influences scripts, see how does the time zone setting affect indicators and strategies?.

References

Pine Script Language Tutorial (n.d.). Retrieved on December 3, 2016, from https://docs.google.com/document/d/1sCfC873xJEMV7MGzt1L70JTStTE9kcG2q-LDuWWkBeY/

TradingView (n.d.). Script Language Reference Manual. Retrieved on May 4, 2017, from https://www.tradingview.com/study-script-reference/

Published June 3, 2017.
# Related TradingView tutorials
  • How to calculate a TradingView indicator on another indicator?

    TradingView indicators usually calculate on prices. But they can also compute on values plotted by another indicator with the ‘apply indicator’ feature.

  • How to enable or disable TradingView"s dark theme?

    TradingView has a ‘Light’ and a ‘Dark’ theme that affect the appearance of the entire platform. Let"s see how we use night view mode and light mode.

  • Overview: all TradingView keyboard shortcuts

    With TradingView"s shortcuts we can productively work with charts, drawings, Watchlist and screener windows, and scripts in TradingView"s Pine Editor.

« All TradingView platform articles


Email: contact@about.com.vn - Phone: 818.333.007 - Website: Media Search Home
Copyright © 2007 - Noos. All rights reserved