Creating a Simple Technical Forecasting Model on the VIX
Using TradingView to Create A Simple Technical Strategy on the VIX
Technical strategies are trading strategies purely based on technical analysis. These can be price action strategies or indicator-driven strategies. The VIX is also known as the Volatility index and is a time series calculation that can be traded through certain vehicles.
This article proposes a simple strategy on the VIX using the RSI. It is worth noting that this is not a ready-for-deployment strategy but a mere start of what you can do with the RSI.
For the complete collection of candlestick patterns in detail with back-tests and technical strategies, you can check out my newest book with O’Reilly Media. The book features a huge number of classic and modern candlestick patterns as it dwelves into the realm of technical analysis with different trading strategies. The book comes with its own GitHub and is dynamic in nature as it is continuously updated and questions are answered on the O’Reilly platform promptly.
Mastering Financial Pattern Recognition
Amazon.com: Mastering Financial Pattern Recognition eBook : Kaabar, Sofien: Kindle Storeamzn.to
Creating the Strategy
The strategy on the VIX relies on the RSI’s conservative technique or what is also known as the exit technique. We can take the hourly values of the VIX or even the daily values (with optimization required). The conditions for the strategy are as follows:
A long (buy) signal is generated whenever the 12-period RSI surpasses 35. The position is held for 5 periods before liquidating.
A short (sell) signal is generated whenever the 12-period RSI breaks 65. The position is held for 5 periods before liquidating.
Now before we see any results, it is important to know the dangers of overfitting. Overfitting is when you try to optimize so hard the parameters of the past that you get the perfect strategy with a smooth equity curve that is too good to be true (like the ones we constantly see on social media).
The above parameters have not been found now but a few months ago and seem to continue to add value. By saying “add value”, it means that the signals are far from perfect but are on average predictive.
The code for the strategy is as follows:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Sofien-Kaabar
//@version=5
strategy("RSI Exit", overlay=true, margin_long=100, margin_short=100, commission_type = strategy.commission.percent, commission_value = 0.01)
lookback = input(defval = 14, title = 'Lookback')
oversold = input(defval = 30, title = 'Lower Barrier')
overbought = input(defval = 70, title = 'Upper Barrier')
duration = input(defval = 5, title = 'Duration')
rsi = ta.rsi(close, lookback)
buy_signal = rsi > oversold and rsi[1] < oversold
sell_signal = rsi < overbought and rsi[1] > overbought
if (buy_signal)
strategy.entry("Long", strategy.long)
strategy.close(id = "Long", when = ta.barssince(buy_signal) == duration or buy_signal == true or sell_signal == true)
if (sell_signal)
strategy.entry("Short", strategy.short)
strategy.close(id = "Short", when = ta.barssince(sell_signal) == duration or buy_signal == true or sell_signal == true)
We can notice that the equity curve is going up but not as smooth as we might want it to be. This is closer to real life situations where extremely smooth equity curves are unlikely to exist especially with simplistic strategy like this one.
If we want to interpret the results, we can say that on 394 trades, we were profitable on 52.79% of them (~208 trades) and for every $1 we risked, we gained 1.332.
If you want to see how to create all sorts of algorithms yourself, feel free to check out Lumiwealth. From algorithmic trading to blockchain and machine learning, they have hands-on detailed courses that I highly recommend.
Learn Algorithmic Trading with Python Lumiwealth
Learn how to create your own trading algorithms for stocks, options, crypto and more from the experts at Lumiwealth. Click to learn more