Skip to content
Algo Trade Analytics Docs
Pine library page — review pending. This page is preserved for compatibility but is not part of the reviewed search index. Check the official Pine Script v6 reference before relying on its explanation, signature, or example.

year - Pine Script Variable

Current bar year in exchange timezone.

int

series

  • The value is derived from the bar’s opening time, so overnight sessions can report the prior year on the first bar.
  • Note that this variable returns the year based on the time of the bar’s open. For overnight sessions (e.g. EURUSD, where Monday session starts on Sunday, 17:00) this value can be lower by 1 than the year of the trading day.
//@version=6
indicator("Yearly separators", overlay=true)
isNewYear = ta.change(year)
plotshape(isNewYear, style=shape.flag, location=location.top, size=size.tiny)