Skip to content

dayofweek - PineScript Variable

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

int

series

  • Values follow Pine’s enumeration: Sunday = 1, Monday = 2, … Saturday = 7.
  • Overnight sessions can report the previous calendar day on the first bar of the session.
  • Combine with time_tradingday to focus on the trading-date weekday rather than the bar’s opening timestamp.
//@version=5
indicator("Weekend shading", overlay=true)
isWeekend = dayofweek == dayofweek.saturday or dayofweek == dayofweek.sunday
bgcolor(isWeekend ? color.new(color.gray, 88) : na,
title="Weekend")