Print Page  
MISC / UTILITY
WeekDay
Full Description

With daily simulations it is sometimes desirable to restrict buying to a specific day of the week. You can almost do this with one rule:

WeekDay=2

This will restrict buying to happen only on Mondays (2), however when Monday is a holiday, buying will not occur for the whole week. Another function is needed to allow buying on Tuesday when Monday is a holiday: PrevBarDaysAgo. This function returns the number of calendar days since the last trading day (trading days are called "bars"). Add it to the Buy rule like this:

WeekDay=2 OR ( WeekDay = 3 AND PrevBarDaysAgo>=3 )

The right part of the rule is only true when the trading day is Tuesday and the last trading day was 3 days ago. This condition only happens when Monday is a holiday since the stock market is never closed for two consecutive work days.

One can also append this rule to portfolio sell rules in order to limit their activation to a single day in the week. This is potentially useful for daily-rebalancing simulations. Use this with a logical and:

MktCap>1000 and WeekDay=2

This will only sell stocks with a market capitalization greater than $1 billion on a Monday. Forewarning: This usage is useless in the screen; because there are no separate buy and sell rules, the screen will end up only owning stocks on Monday and sell all of them on Tuesday.