Reversal Day Strategy (Amibroker And Tradestation Code)

The original article can be found here.

Logic in plain English (bullish reversal day):

  • Today’s low is lower than yesterday’s close
  • Today’s close is higher than yesterday’s close
  • The five-day RSI must be lower than 35

Logic in plain English (bullish reversal day):

  • Today’s high is higher than yesterday’s high
  • Today’s close is lower than yesterday’s close
  • The five-day RSI must be higher than 65

Amibroker code (bullish reversal day):

oddis=Optimize("Trading Day",5,1,25,1);

Buy=  L<Ref(L,-1) AND C>Ref(C,-1) AND RSI(5)<35;
buyPrice=Close;
Sell= 0;   
sellPrice=Close ;

Bullish:

{
Strategy - Bullish reversal day
https://www.quantifiedstrategies.com/lessons/reversal-day-strategy-amibroker-code/
}

Inputs: 
	RsiLookback(5),
	Treshold(35),
	HoldBars(5);
	
if L < L[1] AND C > C[1] AND RSI(Close, RsiLookback) < Treshold  Then
	Buy at this bar close;
	
if Barssinceentry(0) >= HoldBars then
	Sell at this bar close;

Amibroker code (bearish reversal day):

oddis=Optimize("Trading Day",1,1,25,1);

Buy=  C<Ref(C,-1) AND RSI(5)>65 AND H>Ref(H,-1) ;
buyPrice=Close;
Sell= 0;   
sellPrice= Close ;

Tradestation:

{
Strategy - Bearish reversal day
https://www.quantifiedstrategies.com/lessons/reversal-day-strategy-amibroker-code/
}

Inputs: 
	RsiLookback(5),
	Treshold(65),
	HoldBars(5);
	
if H > H[1] AND C < C[1] AND RSI(Close, RsiLookback) > Treshold  Then
	Buy at this bar close;
	
if Barssinceentry(0) >= HoldBars then
	Sell at this bar close;