public HTSin(DataSeries ds, string description) public static HTSin Series(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} Compute Dominant Cycle Phase Compute the Sine of the Dominant Cycle Phase Return the Sine of the Dominant Cycle Phase at the current bar of the Hilbert Transform Period measured at that bar
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} Compute Dominant Cycle Phase Compute the Sine of the Dominant Cycle Phase Advance the Sine by 45 degrees to compute the HT Lead Sine Return the Lead Sine of the Dominant Cycle Phase at the current bar of the Hilbert Transform Period measured at that 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() { // Flag bars where Hilbert Transform Sin/Lead Sin cross HTSin htsin = HTSin.Series( AveragePrice.Series( Bars ) ); HTLeadSin htleadsin = HTLeadSin.Series( AveragePrice.Series( Bars ) ); ChartPane HTSinPane = CreatePane( 50, false, true ); PlotSeries( HTSinPane, htsin, Color.Blue, LineStyle.Solid, 1 ); PlotSeries( HTSinPane, htleadsin, Color.Red, LineStyle.Solid, 1 ); for(int bar = 2; bar < Bars.Count; bar++) { if( CrossOver( bar, htsin, htleadsin ) ) SetBarColor( bar, Color.Red ); else if( CrossUnder( bar, htsin, htleadsin ) ) SetBarColor( bar, Color.Blue ); } } } }