Quick Search
»

# Hilbert Transform | HTInPhase

### Syntax

```
public HTInPhase(DataSeries ds, string description)
public static HTInPhaseSeries(DataSeries ds)
```

### Parameter Description

 ds The source DataSeries, usually AverageSeries

### Description

The Hilbert Transform is a technique used to generate inphase and quadrature components of a de-trended real-valued "analytic-like" signal (such as a Price Series) in order to analyze variations of the instantaneous phase and amplitude. HTInPhase returns the Hilbert Transform generated InPhase component of the input Price Series.

### Interpretation

The InPhase component is used in conjunction with the Quadrature component to generate the phase of the analytic signal (using the ArcTan function) at a specific bar or for the entire Price Series.

### Calculation

More detailed information concerning the calculation of the Hilbert Transform related functions can be found on the Mesa Software site.

The basic flow for the computation for the InPhase component is:

```Compute the Hilbert Transform
{Detrend Price}

Return the InPhase component at the current bar of the Hilbert Transform computed at that bar
```

### Example

```
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()
{
// Color bars based on relative positions of Quadrature and In-Phase
HTInPhase hti = HTInPhase.Series( AveragePrice.Series( Bars ) );

ChartPane HTQuadPane = CreatePane( 50, true, true );
PlotSeries( HTQuadPane, hti, Color.DarkBlue, LineStyle.Solid, 2 );
PlotSeries( HTQuadPane, htq, Color.LightBlue, LineStyle.Solid, 2 );

for(int bar = 0; bar < Bars.Count; bar++)
{
if( hti[bar] > htq[bar] )
SetBarColor( bar, Color.DarkBlue );
else
if( hti[bar] < htq[bar] )
SetBarColor( bar, Color.LightBlue );
}
}
}
}
```