$FB RSI Strategy This post is part of a broader series on technical analysis available on my website, www.andrewshamlet.net . Feel free to reach out with comments or questions: [email protected] // @andrewshamlet Summary The Relative Strength Index (RSI) is a momentum indicator that compares the magnitude of recent gains and losses over a specified time period. RSI values range from 0 to 100. For this strategy, we buy$FB when the RSI is less than 30, and we will sell $FB when the RSI is greater than 70. The RSI will be calculated at a minutely frequency, as opposed to a daily frequency. • During 01/01/16 – 12/31/16, • The RSI Strategy produces 32.2% return, resulting in$3,220 pre-tax return.
• FB Buy & Hold produces 10.0% return, resulting in $1,000 pre-tax return. • SPY Buy & Hold produces 12.0% return, resulting in$1,200 pre-tax return.
• Compared to the SPY Buy & Hold, the RSI Strategy produces $2,220 Alpha whereas FB Buy & Hold produces ($200) Alpha, both on $10,000, principal. 137 Loading... Total Returns -- Alpha -- Beta -- Sharpe -- Sortino -- Max Drawdown -- Benchmark Returns -- Volatility --  Returns 1 Month 3 Month 6 Month 12 Month  Alpha 1 Month 3 Month 6 Month 12 Month  Beta 1 Month 3 Month 6 Month 12 Month  Sharpe 1 Month 3 Month 6 Month 12 Month  Sortino 1 Month 3 Month 6 Month 12 Month  Volatility 1 Month 3 Month 6 Month 12 Month  Max Drawdown 1 Month 3 Month 6 Month 12 Month import talib import numpy as np import pandas as pd def initialize(context): context.stocks = symbols('FB') context.pct_per_stock = 1.0 / len(context.stocks) context.LOW_RSI = 30 context.HIGH_RSI = 70 set_benchmark(sid(42950)) def handle_data(context, data): prices = data.history(context.stocks, 'price', 40, '1d') rsis = {} for stock in context.stocks: rsi = talib.RSI(prices[stock], timeperiod=14)[-1] rsis[stock] = rsi current_position = context.portfolio.positions[stock].amount if rsi > context.HIGH_RSI and current_position > 0 and data.can_trade(stock): order_target(stock, 0) elif rsi < context.LOW_RSI and current_position == 0 and data.can_trade(stock): order_target_percent(stock, context.pct_per_stock) record(FB_rsi=rsis[symbol('FB')]) There was a runtime error. 4 responses • During 05/19/12 – 12/31/16, • The RSI Strategy produces 147.4% return, resulting in$14,740 pre-tax return.
• FB Buy & Hold produces 238.5% return, resulting in $23,850 pre-tax return. • SPY Buy & Hold produces 89.6% return, resulting in$8,960 pre-tax return.
• Compared to SPY Buy & Hold, the RSI Strategy produces $5,780 Alpha whereas FB Buy & Hold produces$14,890 Alpha, both on $10,000 principal. • Thus, on the broader time horizon, FB Buy & Hold outperforms the RSI Strategy. • The question still stands: what about 2016 makes the RSI Strategy superior in performance to FB Buy & Hold? 30 Loading... Total Returns -- Alpha -- Beta -- Sharpe -- Sortino -- Max Drawdown -- Benchmark Returns -- Volatility --  Returns 1 Month 3 Month 6 Month 12 Month  Alpha 1 Month 3 Month 6 Month 12 Month  Beta 1 Month 3 Month 6 Month 12 Month  Sharpe 1 Month 3 Month 6 Month 12 Month  Sortino 1 Month 3 Month 6 Month 12 Month  Volatility 1 Month 3 Month 6 Month 12 Month  Max Drawdown 1 Month 3 Month 6 Month 12 Month import talib import numpy as np import pandas as pd def initialize(context): context.stocks = symbols('FB') context.pct_per_stock = 1.0 / len(context.stocks) context.LOW_RSI = 30 context.HIGH_RSI = 70 set_benchmark(sid(42950)) def handle_data(context, data): prices = data.history(context.stocks, 'price', 40, '1d') rsis = {} for stock in context.stocks: rsi = talib.RSI(prices[stock], timeperiod=14)[-1] rsis[stock] = rsi current_position = context.portfolio.positions[stock].amount if rsi > context.HIGH_RSI and current_position > 0 and data.can_trade(stock): order_target(stock, 0) elif rsi < context.LOW_RSI and current_position == 0 and data.can_trade(stock): order_target_percent(stock, context.pct_per_stock) record(FB_rsi=rsis[symbol('FB')]) There was a runtime error. Compared to the SPY Buy & Hold, the RSI Strategy produces$2,220 Alpha
whereas FB Buy & Hold produces ($200) Alpha, both on$10,000,
principal.

The real beauty of the RSI strategy is that for most of the timeframe that \$10,000 principle can be working (on other stocks) for you while you wait for the buy signal.

The question still stands: what about 2016 makes the RSI Strategy superior in performance to FB Buy & Hold?

Luck. And hindsight. That's my best guess.

My second guess is that RSI works best in conjunction with other indicators. 30 and 70 aren't the only aspects to RSI as far as I understand. If RSI steadily stays above 40, that's also a bullish indicator, so in that sense all of 2012-16 the RSI is telling you to buy and hold. Then there are the moments where RSI's valleys move opposite the stock. I don't know. I think it's a lot of hocus pocus.

My own experiments with RSI show it's a great way to lose money during crashes and pullbacks and miss out on gains during strong bullish trends. Sometimes it's amazing how it predicts valleys and peaks right before they happen... and sometimes it's flat out wrong. With some stocks it just bleeds money. So how do you choose which stocks are appropriate to use RSI with?

Is it possible to code that for futures?

I can't seem to get all Futures contracts to run and RSI is indicator to initiate long and short positions