Minute
Minute returns the minute (0 to 59) of a bar's closing time in ProBuilder. Compare consecutive values to detect the chart timeframe or intra-hour timing.
Syntax
MinuteParameters
| Name | Type | Default | Description |
|---|---|---|---|
| N | integer | 0 | Optional bar offset written as Minute[N]. 0 reads the current bar, 1 the previous bar, and so on. |
How it works
Minute extracts the minute component from a bar's closing timestamp. The value reflects the close of the bar, so on a 15-minute chart a bar covering 09:00 to 09:15 reports Minute = 15. The sibling keyword OpenMinute reads the opening timestamp of the same bar and would report 0 for that bar.
Like the other date and time keywords, Minute accepts a history index. Minute[1] reads the previous bar's closing minute, which makes it possible to measure the spacing between consecutive bars and thereby infer the chart timeframe from inside the code.
The reported minute follows the time zone configured in the platform. On timeframes of one hour or more the minute component is usually constant, so the keyword is chiefly relevant on minute-based charts.
Differencing consecutive values requires care at hour boundaries. Moving from a bar closing at 58 to one closing at 03 produces a negative raw difference, which must be corrected by adding back 60.
Examples
Example 1, Detect the timeframe and the last half-hour (Indicator)
// Infer the chart timeframe from the gap between closes
tf = (Minute - Minute[1])
if tf < 0 then
// correct the wrap-around at the top of the hour
tf = 60 - abs(tf)
endif
// Flag bars that close in the second half of the hour
if (Minute > 30) THEN
HalfHour = 1
ELSE
HalfHour = 0
ENDIF
RETURN HalfHourThe variable tf holds the bar spacing in minutes, with the wrap-around at the hour boundary corrected. The plotted value flags bars closing after minute 30.
Example 2, Block entries near the top of the hour (ProOrder)
// Avoid opening positions in the five minutes around news releases
quietPeriod = Minute >= 55 OR Minute <= 2
IF NOT quietPeriod AND close CROSSES OVER Average[20](close) THEN
BUY 1 SHARES AT MARKET
ENDIFThe system refuses new entries when the bar closes within a few minutes of the full hour, a window in which scheduled announcements often spike volatility.
Example 3, Screen only on half-hour closes (ProScreener)
// Match oversold instruments, but only on bars closing at :00 or :30
onGrid = Minute = 0 OR Minute = 30
oversold = RSI[14](close) < 30
SCREENER[onGrid AND oversold] (RSI[14](close) AS "RSI 14")The screener restricts matches to bars whose closing minute falls on a 30-minute grid, keeping results aligned across instruments scanned on fast timeframes.
Common errors and gotchas
- Close time, not open time. Minute reads the bar's closing timestamp. A 15-minute bar opening at 09:00 returns 15, not 0. Use
OpenMinutewhen the rule should reference the moment the bar started. - Negative differences at hour boundaries.
Minute - Minute[1]turns negative when the hour rolls over, for example 03 minus 58. Correct with60 - abs(difference)as in Example 1 before using the result. - Constant on hourly and higher timeframes. On charts of one hour or more, every bar tends to close at the same minute, so minute-based conditions stop discriminating. Reserve the keyword for minute-based charts.
- Time zone dependence. The value follows the platform's time zone setting, so minute-of-hour logic tied to a specific market event can shift when the setting changes.
Related instructions
OpenMinute, minute of the current bar's opening time, the sibling form of Minute.CurrentMinute, minute of the machine clock rather than a bar timestamp.Hour, hour component (0 to 23) of a bar's closing time.Second, second component of a bar's closing time.TIME, full closing time of a bar in HHMMSS format.DayOfWeek, weekday of a bar's closing date.Today, date of the current bar in YYYYMMDD format.
