The calendar year of the current bar's open time, in the exchange time zone.
year is a series int such as 2024. It changes on the first bar of January in the exchange time zone, so a script can reset a counter when the year changes with year != year[1].
Type
series int
Remarks
- year[n] is na before the first bar.
- On Sidechair: the parts are read in the symbol's exchange time zone, the same as
syminfo.timezone. - The function year(time, timezone) does the same for any timestamp and any time zone.
- On a weekly or monthly chart the value is the year of the bar's opening time, so the first weekly bar of January can still read the earlier year.
Example
//@version=6
indicator("New year", overlay = true)
bgcolor(year != year[1] ? color.new(color.red, 80) : na)
plot(year, "Year", display = display.data_window)See also
Runs on Sidechair