Chip Anderson

When Shifting to the Right is Wrong - the DPO Indicator Controversy

 | 

(Here's a repeat of an article I wrote in 2010. The information is still relevant today - and the controversy still rages... -  Chip)

Yesterday, we received a question about our Detrended Price Oscillator (DPO) calculations.  The reader wanted to know why our DPO values for SPY where completely different from the DPO values provided to him by two competing websites - FreeStockCharts.com and VectorVest.

The reader was nice enough to provide pictures of the charts he was looking at and sure enough the DPO values were very different from ours.  Not only that, but the entire indicator line looked completely wrong.


Here's our chart of SPY with the 20-period DPO:

SccSPYDPO

and here's the VectorVest one:

VvSPYDPO
(The FreeStockCharts.com chart was very similar to the VectorVest one.)

As you can see, from mid-November until mid-January, the VectorVest DPO line doesn't drop below the zero line which, in contrast, our DPO line is constantly jumping above and below zero.  What is going on?

As veteran ChartWatchers know, our "Bible" for indicator calculations is the book "Technical Analysis from A to Z" by Stephen Achiles, the founder of Equis, the company behind the popular desktop charting program "MetaStock."  Stephen's book is also online - click here to see his entry for the DPO.

Basically, Achiles calculates the DPO by taking a Simple Moving Average (SMA) with the specified parameter (20 in this case), shifting that SMA to the LEFT by the parameter divided by 2 + 1 (i.e., 11) periods, and then subtracting the shifted SMA's value from the stock's closing price.

You can look back up at the first chart in this article to see the relationship between SPY, the left-shifted SMA and the DPO.

Using that definition, there should always be some (11 in this case) missing bars on the right edge of the chart because the SMA was shifted to the LEFT and is thus undefined for the last 11 periods.  You can clearly see that gap in the chart that accompanies Achiles' online DPO article.

The fact that the VectorVest chart has a DPO that extends all the way to the right edge of the chart was suspicious to us.  On a hunch, we tried shifting the SMA to the RIGHT instead of the left and got the following chart:

SccSMARight
Now, you have to use your imagination somewhat but if you mentally "flatten" the blue line and look at the difference between that blue line and the black price line, you'll notice that it matches the DPO line on the VectorVest chart.

So that explains what is going on - they are shifting the MA line in the wrong direction - but it doesn't explain "Why?"  Both VectorVest and Warden Brothers (the folks behind FreeStockCharts.com) have been around for many years.  Why are their DPO calculations wrong?

After doing more research, the best explanation we could find was provided in the Worden Brothers website on this forum thread.  Towards the end of that thread, they state that the DPO formula is "controversial" and that there are "serveral ways to calculate the DPO."

We don't agree with that statement.  Here's why:

DPOTEST
This is a chart of a fake symbol we just created called $DPOTEST (the black line on the chart).  The values for that symbol increase by $0.01 every day which means that it is in a constant uptrend.  Conceptually, if you "detrend" this symbol, you should get a horizontal line that is at (or really close to) zero.

The blue line on that chart is a 20-period SMA that has been shifted to the left by 11 periods.  The red line is a 20-period SMA that has been shifted to the right by 11 periods.  Clearly the blue line is much closer to the stock's black price line.  Thus a DPO calculated from the blue line will be much closer to zero than one calculated from the red line.  Therefore we believe that shifting the Moving Average to the LEFT like Achelis advocates is the correct thing to do.

We can only speculate that shifting to the right was done to eliminate the gap between the end of the DPO and the right edge of the chart. While that gap is problematic for active traders, completely changing the calculation is not the solution in our opinion.  If you must get rid of the gap, we suggest shifting the entire DPO itself to the right by 11 positions by using "20,11" as the DPO parameter.

We welcome any feedback on this issue.

 

Chip Anderson
About the author: is the founder and president of StockCharts.com. He founded the company after working as a Windows developer and corporate consultant at Microsoft from 1987 to 1997. In this blog, Chip shares his tips and tricks on how to maximize the tools and resources available at StockCharts.com, and provides updates about new features or additions to the site. Learn More
Subscribe to Chip Anderson to be notified whenever a new post is added to this blog!
Excellent. I've seen other sevices that also shift the SMA in the wrong direction. Might it also be possible to get a detrended oscillator using Slope? Wouldn't that give an accurate representation and eliminate the gap at the end? Of course, it would look different than the usual DPO, but wouldn't it be a good detrended price indicator? If so, how would you suggest implementing and using it?
Thanks Chip, great article and your explanation is very clear. However when digging further into the link for the referenced article, S. Achiles "Technical Analysis from A to Z" (FIRST edition), it becomes a little confusing. The example and key formula are stated as " DPO = Close - (Moving Average "((n/2) +1)" days ago), I think this is the main point of all the confusion. In the SECOND edition of his book the example and formula have been updated to state, DPO = Close - (Moving Average "((n/2) +1)" days in the FUTURE) . To further clarify the issue he added a spreadsheet example of the calculations which directly addresses why the last "((n/2)+1) days are blank and why the indicator is LEFT shifted. Hope this helps. cheers Gord
comments powered by Disqus