API ChartStyles Community Components Community Indicators IndexDefinitions Knowledge Base Misc Optimizers PosSizers Providers Standard Indicators TASC Traders Tips TASCIndicators Visualizers |

**Main Page**- Category List
- Knowledge Base
- Traders Tips
- Indicator documentation
- Addin examples

Advanced Search »

```
public HTSin(DataSeries ds, string description)
public static HTSin Series(DataSeries ds)
```

ds |
The source DataSeries, usually AverageSeries |

Quoting from

"A clear, unequivocal cycle mode indicator can be generated by plotting the Sine of the measured phase angle advanced by 45 degrees. This leading signal crosses the sinewave 1/8th of a cycle BEFORE the peaks and valleys of the cyclic turning points, enabling you to make your trading decision in time to profit from the entire amplitude swing of the cycle. A significant additional advantage is that the two indicator lines don't cross except at cyclic turning points, avoiding the false whipsaw signals of most "oscillators" when the market is in a Trend Mode. The two lines don't cross because the phase rate of change is nearly zero in a trend mode. Since the phase is not changing, the two lines separated by 45 degrees in phase never get the opportunity to cross."

The basic flow and simplified pseudo code for the computation for the Dominant Cycle Phase as part of the computation of the Dominant Cycle is:

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

The basic flow and simplified pseudo code for the computation for the HTLeadSin is:

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 );
}
}
}
}