Analyzing the DVI Indicator – Entry Power

January 15, 2014

(This article was first published on Quintuitive » R, and kindly contributed to R-bloggers)

In a recent post, I did some analysis of the efficiency of the DVI indicator. That was pretty much all I had to say back then, but that quickly changed. While reading Building Reliable Trading Systems, by Keith Fitschen I stumbled upon an alternative way to visualize entry efficiency – the entry power.

Entry Power

The chart shows the average return x-days after an entry. It conveys the expected average returns for an individual trade. As we previously found out, short positions tend to deteriorate with time. This chart however reveals the peak – achieved at about 5th day into the trade. Hmm, can we benefit from a limit on the maximum number of days into the trade?

It’s worth looking at the same chart but using volatility adjusted returns. Just to make sure that the volatility is not skewing the mean.

Entry Power with Volatility

Looks more or less the same.

If you wonder how the chart was generated – I used a couple of R packages: ggplot2, ggthemes, and a few utility functions, which I am too lazy to extract from my environment. Hence, I’d only show the code to compute the entry power:

entry.power = function(prices, entries.index, following.bars=seq(1, 100), position=1, nvolatility=NA) {
   res = rep(NA, NROW(following.bars))
   for(ii in following.bars) {
      rets = ROC(prices, n=ii, type="discrete")
      if(! {
         vola = TTR:::volatility(prices, n=nvolatility, N=252, calc="close")
         rets = rets / vola
      rets = lag.xts(rets, -ii)*position
      res[ii] = mean(as.numeric(rets[entries.index]), na.rm=TRUE)

Very elegant IMO, but isn’t that almost always the case with R? ;) If you are often dealing with time series – notice the use of lag.xts. IMO it’s worth understanding why I prefer lag.xts over lag. Leaving it to you.

And if you are looking for a good read on trading system development, I’d strongly recommend Keith Fitschen’s Building Reliable Trading Systems!

To leave a comment for the author, please follow the link and comment on their blog: Quintuitive » R. offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.