dayofweek - PineScript Variable
dayofweek
Section titled “dayofweek”Overview
Section titled “Overview”The day number of the week, in the exchange time zone, calculated from the bar’s opening UNIX timestamp.
intQualifier
Section titled “Qualifier”series
Remarks
Section titled “Remarks”- 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_tradingdayto focus on the trading-date weekday rather than the bar’s opening timestamp.
Example
Section titled “Example”//@version=5indicator("Weekend shading", overlay=true)
isWeekend = dayofweek == dayofweek.saturday or dayofweek == dayofweek.sunday
bgcolor(isWeekend ? color.new(color.gray, 88) : na, title="Weekend")