dayofweek

The dayofweek namespace provides integer-like constants representing days of the week. These constants are used to compare against the built-in dayofweek variable, which holds the day of the current bar’s timestamp.

Quick Example

from pynecore.lib import script, dayofweek, dayofweek as dow_var, close, bar_index, label

@script.indicator(title="Weekend Marker", overlay=True)
def main():
    if dow_var == dayofweek.monday:
        label.new(bar_index, close, "Monday open")

Note: dayofweek serves dual purpose — import it both as the namespace (for constants) and as the built-in variable (for the current bar’s day). In practice, use an alias to avoid shadowing: from pynecore.lib import dayofweek as dow_var for the variable, and dayofweek.monday etc. for constants.


Constants

All constants are of type DayOfWeek, which behaves like an integer in comparisons.

ConstantDescription
dayofweek.sundaySunday (1)
dayofweek.mondayMonday (2)
dayofweek.tuesdayTuesday (3)
dayofweek.wednesdayWednesday (4)
dayofweek.thursdayThursday (5)
dayofweek.fridayFriday (6)
dayofweek.saturdaySaturday (7)

Usage

Compare the built-in dayofweek variable against these constants:

is_friday: bool = dayofweek == dayofweek.friday
is_weekend: bool = dayofweek in (dayofweek.saturday, dayofweek.sunday)