The Detrended Price Oscillator (DPO) removes the trend in prices - or other series - by subtracting a moving average of the price from the price.
DPO(x, n = 10, maType, shift = n/2 + 1, percent = FALSE, ...)
A object of the same class as x
or a vector (if try.xts
fails) containing the DPO values.
Price, volume, etc. series that is coercible to xts or matrix.
Number of periods for moving average.
A function or a string naming the function to be called.
The number of periods to shift the moving average.
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 maType
function.
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.
Joshua Ulrich
The Detrended Price shows cycles and overbought / oversold conditions.
The following site(s) were used to code/document this
indicator:
https://school.stockcharts.com/doku.php?id=technical_indicators:detrended_price_osci
See EMA
, SMA
, etc. for moving average
options; and note Warning section. See MACD
for a general
oscillator.
data(ttrc)
priceDPO <- DPO(ttrc[,"Close"])
volumeDPO <- DPO(ttrc[,"Volume"])
Run the code above in your browser using DataLab