Modified on 2009/07/11 08:45 by Eugene — Categorized as: Standard Indicators


public DPO(WealthLab.DataSeries source, int period, string description)
public static WealthLab.Indicators.DPO Series(WealthLab.DataSeries source, int period)

Parameter Description

source Data series
period Simple Moving Average period


The Detrended Price Oscillator (DPO) is an indicator that attempts to eliminate the trend in prices. Detrended prices allow you to more easily identify cycles and overbought/oversold levels.


Analyzing the shorter-term cycles inside of the longer-term cycles can be helpful in identifying turning points in the longer term cycle. Like other oscillators, the Detrended Price Oscillator can be used in different ways.


DPO = Close – X-period Simple Moving Average [(X/2)+1 bars ago]

To construct the Detrended Price Oscillator, you need to choose the time span for your analysis. Cycles longer than this time period will be removed from prices, leaving the shorter-term cycles.


The following example buys when the DPO crosses below -5, and exits after 3 bars:

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;

namespace WealthLab.Strategies { public class DPO_Demo : WealthScript { private StrategyParameter paramPeriod; public DPO_Demo() { paramPeriod = CreateParameter("Period", 20, 4, 40, 2); } protected override void Execute() { int period = paramPeriod.ValueInt; DPO dpo = DPO.Series( Close,period ); for(int bar = period; bar < Bars.Count; bar++) { if (IsLastPositionActive) { /* Simple time-based exit */ Position p = LastPosition; if ( bar+1 - p.EntryBar >= 3 ) SellAtMarket( bar+1, p, "After 3 days" ); } else { if( CrossUnder( bar, dpo, -5 ) ) BuyAtMarket( bar+1 ); } } ChartPane dpoPane = CreatePane( 40, true, true ); PlotSeries( dpoPane, dpo, Color.Blue, LineStyle.Solid, 1 ); HideVolume(); } } }