Triple RSI Trading Strategy (Amibroker And Tradestation Code)

The original article can be found here.

Trading rules in plain English:

  • The 5-day RSI is below 30, and
  • The 5-day RSI reading is down for the third day in a row, and
  • The 5-day RSI reading was below 60 three trading days ago, and
  • The close is higher than the 200-day moving average, and
  • If 1-4 are true, then buy at the close.
  • Sell at the close when the 5-day RSI crosses above 50.

Amibroker code:

Buy=   RSI(5)<30 AND RSI(5)<Ref(RSI(5),-1) AND Ref(RSI(5),-1)<Ref(RSI(5),-2) AND Ref(RSI(5),-2)<Ref(RSI(5),-3) AND Ref(RSI(5),-3)<60 AND C>MA(C,200) ;
buyPrice=Close;
Sell = RSI(5)>50;
sellPrice=Close;

Tradestation code:

{
Strategy - Triple RSI
https://www.quantifiedstrategies.com/lessons/triple-rsi-trading-strategy-amibroker-code/
}

Inputs: 
	RsiLength(5),
	RsiTreshold1(30),
	RsiTreshold2(60),
	RsiTreshold3(50),
	RegimeLength(200);
	
Vars:
	r(0);

r = RSI(Close, RsiLength);

if r < RsiTreshold1 AND r < r[1] AND r[1] < r[2] AND r[2] < r[3] AND r[3] < RsiTreshold2 AND C > Average(C, RegimeLength) Then
	Buy at this bar close;
	
if r > RsiTreshold3 then
	Sell at this bar close;