Another simple RSI strategy, yay!

This strategy is applied on the 2-hour interval for XIV (note that the last interval of the day is only 30 minutes, not 2 hours because there are only 6.5 hours during a normal trading day).

1) Calculate RSI2 and RSI5 for XIV

2) When RSI2 crosses below 85 and RSI5 < 70, buy VXX

3) When RSI2 crosses above 70, sell VXX and buy XIV

4) When RSI2 crosses below 85, sell XIV

5) VXX has -1% stop loss and +50% take profit

6) XIV has a "doomsday" stop loss that is placed far away at -25% just in case a black swan/nuke goes off somewhere (warning: will not work if the nuke goes off overnight because XIV will certainly gap down A LOT when the market opens in the morning).

7) Additionally, there is a "panic button" that automatically dumps XIV if it loses 10% or more within an intraday time interval.

8) Lastly, if XIV rises at least $1 above entry price and then drops back down to entry price or below, a break-even stop loss is triggered.

Hedging suggestions: buy monthly SVXY puts that are 30-50% out-of-the-money with about 1% of portfolio value to hedge against black swans. Weekly puts also work; just use about 0.25% of portfolio value. Worst case scenario, XIV/SVXY crashes to $0 from an overnight black swan and **hopefully** your puts will balloon in the morning to offset your XIV/SVXY blow-up, which means total portfolio max drawdown should be contained within -30% instead of -100% (although that's not a guarantee).

Shout out to Mohammed Khalfan for porting my PowerLanguage codes for this strategy from MultiCharts to Quantopian!

Feel free to improve this algo with your own twists! For any collaboration request, please email: [email protected] and [email protected]

UPDATE (9/13/2017): all previous versions of this algo posted in the comments below prior to September 2017 used incorrect codes that I posted originally which cause many VXX trades to not trigger. The current version has been fixed (+20,000%).