Trade last day of the week

Could somebody please help me in my afl. I want to run conditions on the last day of the week (friday..or a day earlier if friday is a holiday or 2 days ealier if both Thursday and Friday are holidays) and then take the trade on Monday opening price.

My AFL includes a Position Scoring logic but please note I do not want to use rotational trading.

I am currently using this but it is not working
Tradeday = DayofWeek() == 5;

What code do I enter so that on no trade days there are no entries or exits?

For me that works. It would generate trades on friday using that code....

So something must be going wrong somewhere else.

do you mean something like tihs?

TradingDay = 				IIf(DayOfWeek()==5,1,					
				IIf(DayOfWeek()==4 AND Ref(DayOfWeek(),1)!=5,1,				
				IIf(DayOfWeek()==3 AND Ref(DayOfWeek(),2)!=5 AND Ref(DayOfWeek(),1)!=4,1,				
				0)))  ;	

Note: This formula is forward looking, so be careful.

For backtesting I do it like this, but you would need a different solution for generating current signals (when you have no future data in your database):

isEndOfWeek = Nz(TimeFrameExpand(1, inWeekly, expandPoint));

You can easily change to monthly, quarterly, etc. just by changing inWeekly to another constant. Many people also do it like this:

dow = DayOfWeek();
isEndOfWeek = dow > Ref(dow,1);

Pretty sure you can find other solutions here in the forum if you just spend a little time searching.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.