A Long-Term Pullback Trading Strategy In The S&P 500 (Amibroker And Tradestation Code)
The original article can be found here.
Code in plain English:
- The close must be above the 200-day moving average.
- The close must be below the 20-day moving average.
- The five-day RSI must be below 45.
- If 1-3 are true, then enter at the close.
- Exit at the close when the five-day RSI ends above 65.
Amibroker code:
SetOption(“initialEquity”,100000);
SetPositionSize(99.75,spsPercentOfEquity);
setOption(“MaxOpenPositions”,1);
setOption(“holdminbars”,1);
SetTradeDelays( 0, 0, 0, 0 );
Buy= Close>MA(C,200) AND Close<MA(C,20) AND RSI(5)<45;
buyPrice=Close;
Sell= RSI(5)>65 ;
sellPrice=Close ;
Tradestation code:
If rsi(c,5)<45 and
close>average(close,200) and
close>average(close,200)
then buy this bar at c;
If rsi(c,5)>65 then sell this bar at c;
