Session, timestamp and weekday answer different questions
Use each value for one purpose. The time variable is the bar opening timestamp in milliseconds; it is not a formatted local time. Changing the chart display time zone does not change Pine calculations. Calendar variables such as dayofweek use the exchange time zone, while the function form lets you choose another zone.
| Question | Pine value or function | Boundary to specify |
|---|---|---|
| Does this bar open inside recurring hours? | time(timeframe.period, session, timezone) | Session hours, day digits and time zone |
| Is this bar inside a dated interval? | time compared with timestamp() | Start inclusive, end exclusive |
| What weekday is the local bar open? | dayofweek(time, timezone) | Calendar day in the chosen zone |
| What trading day does the exchange session use? | time_tradingday | Read its calendar date in UTC; it is not a custom session identifier |