4 Overnight Strategies (Amibroker And Tradestation Code)

The original article could be found here.

Strategy one:

  1. SPY closes at a new 20-day low
  2. Close is above the 200-day moving average.
  3. The IBS indicator<0.5.
  4. Go long at the close, exit at tomorrow’s open.

Buy = Close<Ref(LLV(L,20),-1) AND C>MA(C,200) AND ibs<0.5 ;
BuyPrice=Close;
Sell = C>0 ;
SellPrice=open;

Tradestation code:

{
Strategy 115A - overnight strategy
SPY closes at a new 20-day low
Close is above the 200-day moving average.
The IBS indicator<0.5.
Go long at the close, exit at tomorrow’s open.
}

Inputs:
	IbsTreshold(0.5),
	LowLookback(20),
	RegimeLookback(200);
	
Vars:
	ibs(0);
		
ibs = (Close - Low) / (High - Low);

if Close < Lowest(Low, LowLookback)[1] and Close > Average(Close, RegimeLookback) and ibs < IbsTreshold Then
begin
	buy this bar on close;
	sell next bar on open;
end

Strategy 2:

  1. SPY closes at a new 5-day low.
  2. Close is above the 200-day moving average.
  3. The IBS indicator<0.4.
  4. Go long at the close, exit at tomorrow’s open.

Buy = Close<Ref(LLV(L,5),-1) AND C>MA(C,200) AND ibs<0.4 ;
BuyPrice=Close;
Sell = C>0 ;
SellPrice=open;

Tradestation code:

{
Strategy 115B - overnight strategy
SPY closes at a new 5-day low.
Close is above the 200-day moving average.
The IBS indicator<0.4.
Go long at the close, exit at tomorrow’s open.
}

Inputs:
	IbsTreshold(0.4),
	LowLookback(5),
	RegimeLookback(200);
	
Vars:
	ibs(0);
		
ibs = (Close - Low) / (High - Low);

if Close < Lowest(Low, LowLookback)[1] and Close > Average(Close, RegimeLookback) and ibs < IbsTreshold Then
begin
	buy this bar on close;
	sell next bar on open;
end

Strategy 3:

  1. RSI(5) is below 25.
  2. Close is above the 200-day moving average.
  3. The IBS indicator<0.5.
  4. Go long at the close, exit at tomorrow’s open.

Buy = RSI(5)<25 AND C>MA(C,200) AND ibs<0.5 ;
BuyPrice=Close;
Sell = C>0 ;
SellPrice=open;

Tradestation code:

{
Strategy 115C - overnight strategy
RSI(5) is below 25.
Close is above the 200-day moving average.
The IBS indicator<0.5.
Go long at the close, exit at tomorrow’s open.
}

Inputs:
	IbsTreshold(0.5),
	RsiLookback(5),
	RsiTreshold(25),
	RegimeLookback(200);
	
Vars:
	ibs(0);
		
ibs = (Close - Low) / (High - Low);

if RSI(CLose, RsiLookback) < RsiTreshold and Close > Average(Close, RegimeLookback) and ibs < IbsTreshold Then
begin
	buy this bar on close;
	sell next bar on open;
end

Strategy 4:

  1. The IBS indicator<0.5.
  2. RSI(5)<30
  3. Close is lower than the 50-day moving average

Buy = ibs<0.5 AND RSI(5)<30 AND C<MA(C,50) ;
BuyPrice=Close;
Sell = C>0 ;
SellPrice=open;

Tradestation code:

{
Strategy 115D - overnight strategy
The IBS indicator<0.5.
RSI(5)<30
Close is lower than the 50-day moving average
Go long at the close, exit at tomorrow’s open.
}

Inputs:
	IbsTreshold(0.5),
	RsiLookback(5),
	RsiTreshold(30),
	RegimeLookback(50);
	
Vars:
	ibs(0);
		
ibs = (Close - Low) / (High - Low);

if RSI(CLose, RsiLookback) < RsiTreshold and Close < Average(Close, RegimeLookback) and ibs < IbsTreshold Then
begin
	buy this bar on close;
	sell next bar on open;
end