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.

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)