Sidechair

dayofweek.* constants

Browse the reference

The seven weekday values, dayofweek.sunday (1) to dayofweek.saturday (7), to compare with the dayofweek variable and function.

Try it in the editor

dayofweek.* constants are integers: Sunday is 1, Monday 2, Tuesday 3, Wednesday 4, Thursday 5, Friday 6 and Saturday 7. Compare them with the dayofweek variable, which holds the weekday of the bar's open time in the exchange timezone, or with dayofweek(time, timezone) for another zone.

Because Sunday is 1, a check like dayofweek >= dayofweek.monday and dayofweek <= dayofweek.friday selects weekdays; the numbers are not zero-based.

Constants

NameValueDescription
dayofweek.friday6Friday.
dayofweek.monday2Monday.
dayofweek.saturday7Saturday.
dayofweek.sunday1Sunday.
dayofweek.thursday5Thursday.
dayofweek.tuesday3Tuesday.
dayofweek.wednesday4Wednesday.

Remarks

  • Crypto symbols trade every day, so Saturday and Sunday bars exist. Stock charts have no weekend bars.

Example

Pine ScriptHighlight MondaysOpen in editor
//@version=6
indicator("Mondays", overlay = true)
isMonday = dayofweek == dayofweek.monday
bgcolor(isMonday ? color.new(color.blue, 88) : na)
plotshape(isMonday and dayofweek[1] != dayofweek, "Monday open", shape.diamond, location.top, color.blue)
plot(close, "Close", color.gray)

See also

Runs on Sidechair