Skip to content
Algo Trade Analytics Docs
Pine library page — review pending. This page is preserved for compatibility but is not part of the reviewed search index. Check the official Pine Script v6 reference before relying on its explanation, signature, or example.

time - Pine Script 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=6
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")