time_tradingday - PineScript Variable
time_tradingday
Section titled “time_tradingday”Overview
Section titled “Overview”time_tradingday returns the timestamp for 00:00 UTC of the trading day that contains the current bar. This is especially useful on overnight markets where the session spans two calendar days.
Remarks
Section titled “Remarks”- Unlike
time, this value always aligns to 00:00 UTC of the trading day, even if the session opens the prior evening. - On resolutions above
"1D", the value corresponds to the final trading day captured inside the aggregated bar. - Useful for grouping bars by trading day or aligning session-based calculations across symbols.
Example
Section titled “Example”//@version=5indicator("Trading day comparison", overlay=false)
dayOfWeekExchange = dayofweek(time)dayOfWeekTrading = dayofweek(time_tradingday, "UTC+0")
plot(dayOfWeekExchange, "Exchange day", color=color.blue)plot(dayOfWeekTrading, "Trading day UTC", color=color.teal)
bgcolor(dayOfWeekExchange != dayOfWeekTrading ? color.new(color.orange, 85) : na, title="Overnight session spillover")