All,
I think Yuval has some good ideas that can be used to test the effect with small modifications. I did not proof read his formula but I assume his formula is correct.
That being the case (that Yuval’s formula is good), using <= 5 should get you there in most situations and very close in those situations were it misses the optimal buy-day by a day or two. Specifically, this formula should give you a good idea as to how effective a turn-of-the-month strategy might work:
DaysDiff (AsOfDate, Year * 10000 + Eval(Month < 12, Month, 100) * 100 + 101) <= 5
.
So if the fifth day before the end of the month is a weekend or a holiday it will just try to made the trade the fourth day before the end of the month, and if it cannot it will try again on the third day before the end of the month…
This assumes that occasionally buying the fourth trading day before the end of the month (or the third) still gives you some idea as to how effective the strategy is.
Also it assumes the program fills all the positions in one day when it buys at the end of the month with little cash left: so that it does not keep buying. But clearly this works for some situations, for example where you are buying just one ETF (e.g., SPY) and the sim holds only one position.
Probably, the buy-rule can also be modified in a similar manner with one additional “or” in the rule. Perhaps adding "or month day > 7 " as a fallback would get your there most of the time and give you a pretty good idea as to the effectiveness of the strategy.
I have not tried these formulas in a sim and I apologize if I have missed something basic. But does seem like using inequalities (greater-than or less-than) can go a long way toward seeing how the turn-of-the-month effect works and I wanted to suggest it.
TL;DR. You can probably avoid months where you make no trades at all in the sim with the above minor changes (or similar changes). And it probably accurate enough–after avoiding the problem of months with buys or sells–that if it does not give positive results you might consider using a different strategy.
Thank you Yuval. That should work.
-Jim