Date and time/probuilder · probacktest · proorder · proscreener

TIME

TIME returns the time at which each bar on the chart closes, as an HHMMSS integer. Use Time[N] in ProBuilder to read the time of earlier bars in intraday scripts.

Syntax

probuilder
Time
Time[N]

Parameters

NameTypeDefaultDescription
Ninteger0Index of the bar to read. 0 is the current bar, 1 the previous bar, and so on.

How it works

TIME encodes the time of each bar as a compact integer in HHMMSS layout. A bar formed at 13:15:00 yields 131500: the first two digits are the hour in 24-hour format, the next two the minutes, and the last two the seconds. The value corresponds to the closing side of the bar; the opening moment is exposed separately through OpenTime.

The value follows the local time zone configured in the ProRealTime™ platform, so identical code can match different bars for users with different settings.

Because the format is positional rather than linear, converting it for display requires splitting the digits. Dividing by 10000 moves the hour in front of the decimal point, so 131500 / 10000 gives 13.15, readable as 13:15. This is a presentation trick only: the fractional part holds minutes, not a fraction of an hour, so the result is unsuitable for duration arithmetic. Elapsed-time calculations belong to Timestamp and OpenTimestamp, which count linear seconds.

The bracket index gives access to history. Time[1] reads the previous bar's time, which supports checks such as detecting the first bar of a session by comparing consecutive values.

Examples

Example 1, Converting bar time to a readable number (Indicator)

probuilder
// Convert the current bar time into an HH.MM style number
myTime = Time[0] / 10000
RETURN myTime

If the current bar time is 131500, the plot shows 13.15, which reads as 13:15. The conversion is for display only.

Example 2, Going flat before the session ends (ProOrder)

probuilder
// Close any open position at or after 21:45
IF Time >= 214500 THEN
  SELL AT MARKET
  EXITSHORT AT MARKET
ENDIF

The strategy exits long and short positions once the bar time reaches 21:45, a common pattern for intraday systems that must not hold overnight.

Example 3, Screening for morning breakouts (ProScreener)

probuilder
// Match instruments breaking their 20-bar high during the morning
breakout = high >= Highest[20](high)
morning = Time >= 90000 AND Time <= 120000
SCREENER[breakout AND morning] ("Morning breakout")

The screener combines a price condition with a TIME window so only signals produced between 09:00 and 12:00 are listed.

Common errors and gotchas

  • Treating HHMMSS as linear. 120000 - 115900 equals 4100, not one minute. Subtraction across hour or minute boundaries is meaningless in this format; use Timestamp for durations.
  • Exact equality misses bars. Time = 100000 only matches when a bar closes at exactly 10:00:00. On timeframes that do not align with that instant, the condition never fires. Range comparisons are more reliable.
  • Time zone dependence. Values follow the platform's local time zone setting. The same script can behave differently on a VPS or another user's machine unless the settings match.
  • Open versus close confusion. TIME describes when a bar completes, OpenTime when it starts. On hourly bars the two differ by a full hour, enough to shift session filters by one bar.
  • CurrentTime, wall-clock time rather than a bar's time.
  • OpenTime, opening time of a bar in HHMMSS format.
  • OpenTimestamp, Unix timestamp of the bar open for duration arithmetic.
  • Timestamp, Unix timestamp of the bar close in seconds.
  • Hour, hour component of the bar time.
  • Minute, minute component of the bar time.
  • Second, seconds component of the bar time.
  • Today, date of the current bar in YYYYMMDD format.