SVM Classification using RSI from Various Lengths

First of all, I want to apologize for the lack of posting on the blog these days. I have been insanely busy with work (still am) and had trouble squeezing full posts in.

Today, I thought I would follow up on the previous post on SVM learning. In this post I did exactly what I talked about in the post; the only input in the system is the RSI values for lengths 2 to 30 days associated with their respective results (up vs. down). The SVM algorithm is from the R package kernlab, and the parameters for the SVM itself are nu = 0.2, and C = 10. Those are arbitrarily chosen and absolutely no optimization has been performed, the idea being only to give an example. Furthermore, I by no means suggest that this is the best setup or anything of the sort, I thought this would be a good example since it was previously discussed on the blog. Anyhow, here are the equity curves and some numbers compared to classic MR with RSI 2 50/50 as a proxy and buy and hold.

Just eyeballing the chart, one can see that the SVM strategy adapt better to the the presence of a trend and outperform RSI 2 during the bull market, it also adapted fairly well to the recent turmoil, performing slightly worse than the short term MR strategy. I plan to share some code but don’t want to clutter the blog with lines and lines of code, so once I figure out the best way to do this, (I am thinking a downloadable file or something like it) I will proceed. Finally, if readers have played around with SVM I welcome suggestions and comments as always !



11 thoughts on “SVM Classification using RSI from Various Lengths”

  1. First, great blog!

    Code share would be great. But almost as good would be a description of how the algorithm works (how it is performing the calculation).

    1. Hi BMB,

      Thank you for you comment. For the moment, I think that the inner workings of SVMs is beyond the scope I want for the blog. My goal here was to introduce the tool as a valid area of investigating for the curious reader. However I can send you some papers that explain it pretty well and I welcome any specific questions readers may have, if you are interested drop me an e-mail.


    1. Hello DD,

      Thank you for the paper, it was interesting. I personally always preferred kernlab’s ksvm function when using SVMs. The code is coming.


  2. Interesting post.

    What happens if you start your S&P history earlier, say 10 years or so? Do you still have these results? I’d like to see the strategy then as well. Is it robust?


    1. Hey Costas,

      It does not perform as well before the daily mean reversion era. Hence why I didn’t posted the results in the test. To make it more robust, I could perhaps include momentum variables like macd or EMAs to improve the performance up to the 2000s.



  3. Great post!

    Did you try taking only the high probability (say when the confidence level is > 90%) trades?

Comments are closed.