Skip to content
StatePath
Tool Atlastime.hour_of_day

Tool

Hour of Day

time.hour_of_day

MarketTime

Inputs

No typed inputs.

Outputs

Buffer (time series)

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.

Hour of Day overview diagram00:0008:0014:0024:00

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.

Connects to

Feeds into

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

  • Treating the hour as local time — it reflects the bar timestamp's time zone (often broker/server time), which may differ from your own.
  • 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.

See also