public HTPeriod(DataSeries ds, string description) public static HTPeriod(DataSeries ds)

Compute the Hilbert Transform {Detrend Price} {Compute InPhase and Quadrature components} Compute the Period of the Dominant Cycle {Use ArcTangent to compute the current phase} {Resolve the ArcTangent ambiguity} {Compute a differential phase, resolve phase wraparound, and limit delta phase errors} {Sum DeltaPhases to reach 360 degrees. The sum is the instantaneous period.} {Resolve Instantaneous Period errors and smooth} Return the Hilbert Transform Period measured at the current bar

using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using Community.Indicators;namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { // This code creates an adaptive moving average. // The period of the MA is based on the HTPeriod for the bar HTPeriod htp = HTPeriod.Series( AveragePrice.Series( Bars ) ); DataSeries DynSMA = Close-Close; int n = 0; ChartPane HTPeriodPane = CreatePane( 50, true, true ); PlotSeries( HTPeriodPane, htp, Color.Blue, LineStyle.Solid, 1 ); for(int bar = 40; bar < Bars.Count; bar++) { n = (int)Math.Round( htpbar ); if( n < 2 ) n = 2; DynSMAbar = SMA.Series( AveragePrice.Series( Bars ), n )bar; } PlotSeries( PricePane, DynSMA, Color.Navy, LineStyle.Solid, 2 ); } } }