Home » Symbol Information Functions » Understanding syminfo.timezone Function in Pine Script

Understanding syminfo.timezone Function in Pine Script

Photo of author
Published on

Pine Script, the scripting language used on the TradingView platform, allows traders and developers to create custom indicators, strategies, and other trading tools. One of the useful features in Pine Script, especially in its Version 5, is the syminfo.timezone. This article provides an in-depth look at this feature.

What is syminfo.timezone?

In Pine Script, syminfo.timezone is a built-in variable that represents the timezone in which a trading symbol is traded. It returns a string corresponding to a timezone from the IANA time zone database. For example, for stocks traded on the New York Stock Exchange, syminfo.timezone would return "America/New_York".

Example Usage

indicator("My Timezone Indicator", overlay=true)

var string myTimezone = syminfo.timezone

// Modified to plot at the beginning of a new trading day
newDay = dayofweek != dayofweek[1]
plotchar(newDay, "New Day", "▲", location.top, color=color.green, text='myTimezone')

Detailed Walkthrough of the Code

  1. We define a boolean condition newDay that is true at the start of each new trading day.
  2. We use plotchar to plot a symbol ("▲") at the top of the chart whenever newDay is true.
  3. The timezone information (myTimezone) is displayed as text with the plotted character.

Key Features and Takeaways

  • Function Usability: syminfo.timezone is straightforward to use and requires no parameters. It automatically fetches the timezone of the symbol being charted.
  • Syntax and Application: The syntax is simple, involving just the variable name. It can be assigned to other variables or directly used in functions.
  • Practical Utility: This feature is particularly useful for traders who deal with instruments across multiple timezones, ensuring they are aware of the market hours relative to their local time.

Leave a Comment