Analyzing the DVI Indicator – Entry Power

[This article was first published on Quintuitive » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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 about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)