Skip to content

time_tradingday - PineScript Variable

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.

  • 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.
//@version=5
indicator("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")