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_close - Pine Script Variable

time_close provides the close timestamp for the current bar, expressed in milliseconds since 1970-01-01 UTC. On price-based charts (Renko, Line Break, etc.) the latest realtime bar returns na because the closing moment is not known until completion.

  • Use together with timenow to calculate time remaining in the bar: (time_close - timenow) / 1000.
  • Historical bars on price-based charts return valid timestamps even when realtime bars do not.
  • When applying session filters, time_close respects the chart’s exchange timezone.
//@version=6
indicator("Seconds until close", overlay=false)
remaining = (time_close - timenow) / 1000.0
remaining := math.max(remaining, 0)
plot(remaining, "Seconds left", color=color.orange)
hline(0, "Close", color=color.gray)