-
-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DPO documentation is confusing #47
Comments
Closing as duplicate of #1. If you truly believe the calculation in the 3 references provided in |
I think the way TTR does is wrong. You didn't look at the details I provided. The reference shows: DPO = Close - (Moving Average ((n/2)+1) days ago) But what TTR does is using Moving Average ((n/2)+1) days in future!!! |
I did look at the details you provided, and they're not the correct way to calculate the DPO indicator. Since you agree that all the references are correct, I'll quote some sections of the StockCharts reference. Here they talk about the "displaced" moving average, which "centers" the moving average. Centered moving averages look into the future, by definition.
They also explicitly say it is not designed for momentum signals because the displaced (centered) moving average is set in the past.
Then they explicitly say that what you suggest defeats the purpose of the DPO indicator.
|
I see. Thanks! But now I think the three refereces are all different with each other. Totally confused.
I think the third way is only useful for visualization, otherwise it does not make sense technically. |
Yes, the references are confusing. I should probably remove the MetaStock and FM Labs references, since they aren't internally consistent. The chart on the MetaStock page suggests a centered MA is used, but that is not clear from the text. The FM Labs text says, "Note that the calculation shifts the results (shift = term / 2 + 1) periods, so the last shift periods will be zero." The only way the last "shift" periods are zero are if you use a centered MA. But there's nothing in the formula that suggests the MA is centered. |
Thanks for your reply. I searched google scholar, and found out most papers (even though very few) used the first way (curent price - moving average n/2+1 days ago), which is based on this paper:
cited 589 times. The displacement way is very likely from this book:
I looked at the origin. It says:
This explaination is almost the same as: http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:detrended_price_osci Let's review this from StockCharts:
This DPO can be calculated by any n period and shift to past. If I can look into future, any cycle can be identified. Look at the e.g. figure for Nasdaq 100 ETF (QQQQ). Cycles in the past are perfect, but it ends with displaced SMA. Then there is no indication that whether recent prices are in a cycle or not. So it is not an technical indicator but more like a visualization tool. Overall, I still doubt the effectiveness of this method. |
Re-opening so I remember to update the documentation. |
The way of calculating DPO: Detrended Price Oscillator is confusing!
For Simple Moving Average, if I have a series
v <- c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
ma <- TTR::SMA(v, n=5)
NA NA NA NA 3 4 5 6 7 8
It is calculated by rolling mean from 1:5 -> 5:10
However, when I do DPO, it gives
TTR::DPO(v,n=5)
NA -1 -1 -1 -1 -1 -1 NA NA NA
It is calculated by: v[1:7] - ma[4:10], shifted by (n/2+1=3)
It uses current price to substract future moving average.
The correct way is: v[4:10] - ma[1:7], using current price to substract previous moving average, and the results should be:
NA NA NA NA NA NA NA 5 5 5
A real example here using TTR::SMA and TTR::DPO:
This looks into future.
The text was updated successfully, but these errors were encountered: