Tool
Hour of Day
time.hour_of_day
Inputs
No typed inputs.
Outputs
An integer hour of the day (0–23) for the current bar. Every bar within the same clock hour returns the same value.
Reports the hour (0–23) of the current bar's timestamp. Traders use it to restrict activity to specific hours or trading sessions.
How it works
For each bar it reads the timestamp and returns the hour component, 0 through 23. It ignores price entirely and simply tells you what time of day the bar belongs to.
Modes
Read the hour on the UTC wall clock.
Read the hour on the feed clock (Europe/Athens), the zone the data source writes its bars on.
Read the hour on the Europe/London wall clock.
Read the hour on the America/New_York wall clock.
Read the hour on the Asia/Tokyo wall clock.
Configuration
The wall clock the hour is read on: UTC by default, the feed clock (Europe/Athens, the zone the data source writes its bars on) or a session's own zone. An hour window written for London belongs on Europe/London.
Connects to
Examples
- Filter: only allow entries between 08:00 and 16:00 by passing the hour into condition.compare (3-operand le).
- Use condition.compare gt on the hour to avoid trading before a chosen morning hour.
Common mistakes
- Reading the hour on the wrong clock: it is read on the node's timezone (UTC by default), so pick the zone your session hours are written in.
- Building an hour window that wraps past midnight (for example 22–2) with a single in_range check — that range is non-contiguous and needs two checks.