public DPO(WealthLab.DataSeries source, int period, string description) public static WealthLab.Indicators.DPO Series(WealthLab.DataSeries source, int period)
DPO = Close – X-period Simple Moving Average [(X/2)+1 bars ago]
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(); } } }