Wealth-Lab Wiki

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

Navigation


Quick Search
»
Advanced Search »


Hilbert Transform | HTLeadSin

RSS

Syntax


public HTLeadSin(DataSeries ds, string description)
public static HTLeadSin Series(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.. HTDCPhase returns the Hilbert Transform Phase of the Dominant Cycle. The Dominant Cycle Phase lies in the range of 0 to 360 degrees. The Hilbert Transform Lead Sine is just the sine of the DC Phase advanced by 45 degrees.

Interpretation

The DC Phase at a specific bar gives the phase position from 0 to 360 degrees within the current Hilbert Transform Period instantaneously measured at that bar. The HTSin is the sine of the DC Phase at a specific bar. The HTLeadSin is the sine of the DC Phase at a specific bar. They are most often used together to identify cyclic turning points.

Quoting from Market Mode Strategies.doc by John Ehlers from MESA Software,

"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."



Calculation

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

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 

Example

This example flags bars where Hilbert Transform Sin/Lead Sin cross:


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

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes. By using this web site, you agree to the terms of this disclaimer and our Terms of Use.

Used under license from FMR Corp. Copyright 2008 FMR Corp. All rights reserved.


ScrewTurn Wiki. Some of the icons created by FamFamFam.