Skip to content
Algo Trade Analytics Docs

weekofyear - Pine Script Variable

The week number of the year, in the exchange time zone, calculated from the bar’s opening UNIX timestamp.

int

series

  • Overnight sessions can report the previous calendar week on the first bar of the trading day.
  • This variable always references the week number corresponding to the bar’s opening time. Consequently, for symbols with overnight sessions (e.g., “EURUSD”, where the “Monday” session starts on Sunday at 17:00 in exchange time), the value may represent a previous calendar week rather than the week of the session’s primary trading day.
//@version=6
indicator("Week number label", overlay=true, max_labels_count=1)
if barstate.islast
label.new(bar_index, high, str.tostring(weekofyear),
style=label.style_label_down)