The Hour function in ProBuilder language is used to retrieve the hour of the day for a specific bar on the chart. This function is particularly useful for strategies that need to execute based on the time of day, such as opening hour trades or strategies that avoid certain market hours.
Hour[N]
Here, N represents the index of the bar from which you want to get the hour. N can be any integer. If N is 1, it refers to the previous bar; if N is 0, it refers to the current bar.
IF (Hour[1] = 9) THEN
lasthourwasnine = 1
ELSE
lasthourwasnine = 0
ENDIF
RETURN lasthourwasnine
This example checks if the hour of the previous bar (Hour[1]) was 9. If true, it sets the variable lasthourwasnine to 1, otherwise, it sets it to 0. The value of lasthourwasnine is then returned, which can be used in further conditions or actions.
Understanding the use of the Hour function can help in creating time-specific trading strategies, which is crucial for markets that show different behaviors at different times of the day.