DVI Performance

This is the next post in the DVI indicator series. After the first two (here and here) analyzed in details the post-entry returns and the entry power of this indicator, it’s time to take a look at the trading performance.

Using the Systematic Investor Toolbox, we get some pretty decent results:

Equity Curve

Equity Curve

Performance Statistics

Performance Statistics

CAGR of 16.15% and Sharpe Ratio of 0.93 is simply amazing, especially considering the fact that this is just a bare-bone implementation. The massive performance over the last few years is simply astonishing and a proof of the robustness of this indicator. Remember, it was introduced by David Varadi from CSS Analytics circa 2008.

As usual, the full source code is available from GitHub. For the code to work properly, you need to install the latest version of the TTR package from R-Forge, which substantially improves the previous DVI implementation. One way to install this necessary package is by running:

install.packages("TTR", repos="http://R-Forge.R-project.org")


  1. Marco says:

    This is one of the best indicators, you are right. I use it also to build some overnight patterns.
    How much leverage would you use at maximum?

  2. ivannp says:

    I’d go all the way to 1.9, which (2.0) is the upper limit for overnight positions on stocks for the account I am using. Lately I have been using futures as the trading vehicle, but haven’t bothered to investigate bigger leverages, and my recollections are that the risk is outside my tolerance. In addition, I have position sizing based on volatility, thus, around events like 2008, my leverage would drop significantly (close to 0 at the craziest of times).

  3. Allen Zhou says:

    I found one mistake in your work. This is kind of hard to be identified, so I hope it will be useful.

    “data$weight[] = bt.apply(signals, function(xx) {dvi.indicator(Cl(xx))[,1]})”
    This is the code with underlying mistake. dvi calculation is wrong.

    bt.apply() calls coredata()
    coredata() transfers a xts class to matrix.
    Cl() calls a matrix turns to be an array
    lag(x) does not work for an array: lag(x) == x
    So “b lag(price), 1, -1)” in TTR:::DVI() always returns zero
    Therefore, your simulation gives more long signals than it supposed to have.

    1. ivannp says:

      Thanks for sharing your findings. This is a bug with older versions of TTR, which I believe I pointed out a while back and it got addressed in the package. The latest version of DVI, from R-forge uses: b <- ifelse( price > lag.xts(price), 1, -1 ), which should work as expected.

  4. tstudent2012 says:

    Please can show the correct format for “gspc.csv” file? I’m having problem with bt.prep(data, align=’keep.all’, dates=dates) . I’m talking about the code here: https://gist.github.com/ivannp/ddaddfe2991d52184c71

Leave a Reply