Skip to content

time - PineScript Variable

time contains the UNIX timestamp (milliseconds since 1970-01-01 UTC) corresponding to the open of the current bar in the chart’s exchange timezone.

  • Values reflect the bar open, so overnight sessions may report the previous calendar day.
  • Pair with helpers like year(time) or weekofyear(time) to derive calendar attributes.
  • For realtime clocks, use timenow (current moment) or time_close (estimated bar close).
//@version=5
indicator("Session shading via time", overlay=true)
start = timestamp("America/New_York", 2024, 1, 2, 9, 30, 0)
finish = timestamp("America/New_York", 2024, 1, 2, 16, 0, 0)
inWindow = time >= start and time <= finish
bgcolor(inWindow ? color.new(color.teal, 88) : na,
title="NY Session on Jan 2, 2024")