DayOfWeek

Category: Date and time

The DayOfWeek function in ProBuilder language is used to determine the day of the week for a specific bar on the chart. This function is particularly useful for strategies that require analysis based on the day of the week, such as avoiding trades on Mondays or closing positions on Fridays.

Syntax:

DayOfWeek[N]

Where N is the index of the bar, with 0 being the current bar, 1 being the previous bar, and so on.

Example:

myDay = DayOfWeek[0]
IF myDay = 1 THEN
    // Actions to take if it's Monday
ENDIF

In this example, the variable myDay is assigned the day of the week of the current bar (today). If today is Monday (where Monday is represented as 1), then the specified actions inside the IF statement will be executed.

  • The days of the week are represented as integers where Monday is 1 and Sunday is 7.
  • This function can be used in various trading strategies, especially those that are sensitive to the timing within the week.

Understanding the DayOfWeek function can help in creating more time-specific trading strategies and in analyzing market behavior on different days of the week without manual date checking.

Related Instructions:

  • CurrentDayOfWeek date and time
  • OpenDayOfWeek date and time
  • Logo Logo
    Loading...