The Detrended Price Oscillator (DPO) removes the trend in prices - or other series - by subtracting a moving average of the price from the price.
Arguments
- x
Price, volume, etc. series that is coercible to xts or matrix.
- n
Number of periods for moving average.
- maType
A function or a string naming the function to be called.
- shift
The number of periods to shift the moving average.
- percent
logical; if
TRUE, the percentage difference between the slow and fast moving averages is returned, otherwise the difference between the respective averages is returned.- ...
Other arguments to be passed to the
maTypefunction.
Note
DPO does not extend to the last date because it is based on a displaced moving
average. The calculation shifts the results shift periods, so the last
shift periods will be zero.
As stated above, the DPO can be used on any univariate series, not just price.
Warning
The detrended price oscillator removes the trend in the series by centering the moving average. Centering the moving average causes it to include future data. Therefore, even though this indicator looks like a classic oscillator, it should not be used for trading rule signals.
References
The following site(s) were used to code/document this
indicator:
https://school.stockcharts.com/doku.php?id=technical_indicators:detrended_price_osci
Examples
data(ttrc)
priceDPO <- DPO(ttrc[,"Close"])
volumeDPO <- DPO(ttrc[,"Volume"])