CurrentHour

Category: Date and time

CurrentHour is a function in ProBuilder language that returns the current hour of the day based on the 24-hour clock format. This function is useful for scripts that need to perform actions based on the time of day, such as opening or closing trades at specific hours.

Syntax:

CurrentHour

Example:

The following example demonstrates how to use the CurrentHour function to check if it is noon and set a variable GoLunch accordingly. If it is 12 PM, GoLunch is set to 1, otherwise, it is set to 0.

IF (CurrentHour = 12) THEN
    GoLunch = 1
ELSE
    GoLunch = 0
ENDIF
RETURN GoLunch

This function does not require any parameters and is straightforward to use, making it accessible for beginners. It is particularly useful in trading algorithms where certain operations need to be timed precisely with market hours or specific times of the day.

Related Instructions:

  • Hour date and time
  • OpenHour date and time
  • Logo Logo
    Loading...