Post-Holiday Effect In Stocks (Amibroker And Tradestation Code)

The original article can be found here.

Backtest 1:

SetOption(“initialEquity”,100000);
SetPositionSize(99.75,spsPercentOfEquity);
setOption(“MaxOpenPositions”,1);

setOption(“holdminbars”,1);
SetTradeDelays( 0, 0, 0, 0 );

oddis=Optimize(“Days after entry”,1,1,5,1);
oddis1=Optimize(“Month”,1,1,12,1);

Buy= ( ( DayOfWeek()==4 AND Ref(DayOfWeek(),1)==1 ) OR ( DayOfWeek()==5 AND Ref(DayOfWeek(),1)==2 ) ) AND Month()==oddis1 ;
buyPrice=Close;
Sell= 0;
sellPrice=Close ;
applyStop(stopTypeNBar,stopModeBars,2,1);

Backtest 2:

oddis=Optimize(“Days after entry”,1,1,5,1);
oddis1=Optimize(“Month”,1,1,12,1);

Buy= ( ( DayOfWeek()==2 AND Ref(DayOfWeek(),-1)==5 ) OR ( DayOfWeek()==1 AND Ref(DayOfWeek(),-1)==4 ) ) AND Month()==oddis1 ;
buyPrice=Close;
Sell= 0;
sellPrice=Close ;
applyStop(stopTypeNBar,stopModeBars,oddis,1);

Tradestation code:

{
Strategy 116A - post-holiday effect
Trading day after a non trading day is a down day (not considering weekends).
For example, if today is TUE and MON was closed. 
}

Inputs: 
	HoldBars(2),
	MonthNo(1);

Vars: rng(0);

if ((Dayofweek(Date) = Thursday and IsHoliday(CalcDate(Date, 1))) or (Dayofweek(Date) = Friday and IsHoliday(CalcDate(Date, 3)))) and Month(date) = MonthNo then 
	buy this bar on close;

if Barssinceentry(0) >= HoldBars then 
	sell this bar on close;





{
Strategy 116B - post-holiday effect
Trading day after a non trading day is a down day, but the next day is up day (not considering weekends).
For example, if today is TUE and MON was closed. 
}

Inputs: 
	HoldBars(1),
	MonthNo(1);

Vars: rng(0);

if ((Dayofweek(Date) = Tuesday and IsHoliday(CalcDate(Date, -1))) or (Dayofweek(Date) = Monday and IsHoliday(CalcDate(Date, -3)))) {and Month(date) = MonthNo} then 
	buy this bar on close;

if Barssinceentry(0) >= HoldBars then 
	sell this bar on close;