Help with Buy on first day of week, and Sell of Last day of week

I didn't know who to buy on first day of week and sell on last day of week, so I coded to buy on Monday and Sell on Friday. Unfortunately, some weeks, Monday or Friday is a holiday. How can I improve my code ?

Monday = DayOfWeek() == 1;
Friday = DayOfWeek() == 5;
Buy = Monday;
Sell = Friday;

Thanks.

Instead of hard coding 1 and 5 you can detect the difference in dayofweek . If one bar change is negative it means that it is beginning of the week. The day before that is the end of the week.

3 Likes