The seven weekday values, dayofweek.sunday (1) to dayofweek.saturday (7), to compare with the dayofweek variable and function.
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
| Name | Value | Description |
|---|---|---|
dayofweek.friday | 6 | Friday. |
dayofweek.monday | 2 | Monday. |
dayofweek.saturday | 7 | Saturday. |
dayofweek.sunday | 1 | Sunday. |
dayofweek.thursday | 5 | Thursday. |
dayofweek.tuesday | 3 | Tuesday. |
dayofweek.wednesday | 4 | Wednesday. |
Remarks
- Crypto symbols trade every day, so Saturday and Sunday bars exist. Stock charts have no weekend bars.
Example
//@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