The Detrended Price Oscillator (DPO) is a technical analysis tool designed to remove the influence of the long-term trend in the pricing data, making it easier to identify cycles and overbought or oversold levels in a market. The DPO highlights the peaks and troughs in price movements, which are indicative of the market’s cyclical nature.
DPO[N](price)
Where N represents the number of periods over which the oscillator is calculated, and price is the price data used (e.g., close, open, high, low, typical price).
// Calculate the 21-period DPO using the typical price
myDPO = DPO[21](typicalprice)
// Initialize a variable to store the maximum DPO value from the past 10 periods
value = 0
FOR i = 1 TO 10 DO
if(myDPO[i] > value) THEN
value = myDPO[i]
ENDIF
NEXT
// Determine if the current DPO is greater than the maximum found
if(myDPO > value) THEN
extremebullish = 1
ELSE
extremebullish = 0
ENDIF
RETURN extremebullish COLOURED(124,252,0)
This example calculates the 21-period DPO based on the typical price and checks if the current DPO value is the highest in the last 10 periods. If it is, it sets extremebullish to 1, otherwise to 0. The result is also colored in a specific RGB color (124, 252, 0).
The DPO is particularly useful for identifying the timing of cycles in the market. By removing the trend, traders can focus on the underlying cycles and potentially improve their timing for entering and exiting trades. However, it’s important to use the DPO in conjunction with other indicators and analysis techniques to confirm signals.