DAYOFWEEK() Function
Overview
The Day of Week function (available from Optuma v1.5 or higher) allows you to reference specific days of the week in your scripts. Each Day is assigned a numerical value:
1 = Sunday
2 = Monday
3 = Tuesday
4 = Wednesday
5 = Thursday
6 = Friday
7 = Saturday
On a show view the base function DAYOFWEEK()
would produce the following result:
You can see the script value oscillates between 1 and 7 based on the day.
Example Script
The following example looks for the Closing price crossing above a 150EMA, but only if it occurs on a Monday:
V1 = DAYOFWEEK() == 2;
V2 = CLOSE() CrossesAbove MA(BARS=150, STYLE=Exponential) ;
V1 and V2
On a chart the script would look like this:
The blue bar shows where the scripted criteria has passed. You can see the close also crossed above the 150EMA on the 29th of November, but as it was not a Monday the script did not pass.