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.

dayofweek - Pine Script 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=6
indicator("Weekend shading", overlay=true)
isWeekend = dayofweek == dayofweek.saturday or dayofweek == dayofweek.sunday
bgcolor(isWeekend ? color.new(color.gray, 88) : na,
title="Weekend")