S&P 500 Mean Reversion Using IBS and RSI (Amibroker And Tradestation Code)
The strategy in plain English:
- IBS (internal bar strength) must be lower than 0.25 (using daily bars).
- RSI (21) must be below 45.
- If 1 and 2 are fulfilled, go long at the close.
- Exit when close is higher than yesterday’s close.
Click here to see the original article.
Amibroker code:
ibs=(close-low)/(high-low);
buy=ibs<0.25 and rsi(21)<45;
buyprice= close;
sell=close>ref(high,-1);
sellprice=Close;
Tradestation code:
{
S&P 500 Mean Reversion Using IBS and RSI (Strategy 63)
IBS (internal bar strength) must be lower than 0.25 (using daily bars).
RSI (21) must be below 45.
If 1 and 2 are fulfilled, go long at the close.
Exit when close is higher than yesterday’s close.
}
Inputs:
IbsTreshold(0.25),
RsiLookback(21),
RsiTreshold(45);
Vars:
Ibs(0);
Ibs = (Close - Low) / (High - Low);
if RSI(Close, RsiLookback) < RsiTreshold and Ibs < IbsTreshold Then
Buy this bar on close;
if Barssinceentry(0) >= 1 and Close > High[1] Then
Sell this bar on close;
Disclosure: We are not financial advisors. Please do your own due diligence and investment research or consult a financial professional. All articles are our opinions – they are not suggestions to buy or sell any securities.
