I am trying to backtest a system whereby you find the last trading day of the month and then buy x days before that and sell y days after it. I've tried everything I can think of but I have not been unable to figure out how to get around days where the market is not open. I've been focused on the dayofyear, month, day, and dayofweek function, but I can't seem to break the code.
Could someone please give me a point on this one? Thank you.
