CurrentDayOfWeek

Category: Date and time

The CurrentDayOfWeek function in ProBuilder language is used to determine the current day of the week. This function is particularly useful in trading algorithms where specific actions might be taken based on the day of the week. The function returns an integer representing the day of the week, where Monday is represented by 1, Tuesday by 2, and so on up to Sunday, which is represented by 7.

Syntax:

CurrentDayOfWeek

Example Usage:

To demonstrate how to use the CurrentDayOfWeek function, consider a scenario where you need to check if the current day is Wednesday. If it is Wednesday, you might want to set a variable Wednesday to 1; otherwise, set it to 0.

IF (CurrentDayOfWeek = 3) THEN
    Wednesday = 1
ELSE
    Wednesday = 0
ENDIF
RETURN Wednesday

This example uses a simple conditional statement to check if the value returned by CurrentDayOfWeek is 3 (which corresponds to Wednesday). Depending on the result, it assigns a value to the variable Wednesday.

Additional Information:

  • The CurrentDayOfWeek function is a zero-parameter function that provides the day of the week as an integer.
  • This function can be very useful in scripts that need to behave differently on certain days of the week, such as avoiding trading on weekends or executing specific strategies on particular weekdays.

Understanding the output of CurrentDayOfWeek is straightforward, making it an excellent tool for both beginners and advanced users in the ProBuilder programming environment.

Related Instructions:

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