Hilbert Transform - Phasor Components (HT_PHASOR)
Summary
Hilbert Transform indicator that decomposes the price series into its in-phase (I) and quadrature (Q) phasor components. Shares the same detrend/Hilbert machinery as the other HT_* cycle functions.
This function is meant for building your own cycle analysis on top of the raw phasor, not as a ready-made signal.
Chart
Chart metadata i
Outputs
outInPhase:line·zero·positive·negativeoutQuadrature:dash_line·zero·positive·negative
Formula
Smooth price with a 4-bar WMA (weights 1,2,3,4 /10). Apply the Hilbert Transform (a=0.0962, b=0.5769, scaled per bar by adjustedPrevPeriod = 0.075*period + 0.54) to get detrender = HT(smoothed) and Q1 = HT(detrender). Output: outInPhase = detrender delayed 3 price bars; outQuadrature = Q1.
Interpretation
I and Q are the Cartesian coordinates of the rotating cycle vector — the same phasor HT_DCPHASE reports as an angle (atan(Q/I)), exposed here raw and unsmoothed, one step before that estimate. There's no standalone I/Q trading rule from Ehlers; the practical signals sit downstream, in HT_DCPERIOD, HT_DCPHASE, HT_SINE, and HT_TRENDMODE, which each smooth this same decomposition into a usable period, phase, or trend/cycle read.
Inputs
inReal— Source price series
Outputs
outInPhase— In-phase component (detrender delayed 3 bars)outQuadrature— Quadrature component (Q1 of the Hilbert Transform)
Properties
Numerical Stability: Initial Unstable Period
| ☐ Overlap Input |
| ✅ Independent Y-Axis i |
| ☐ Candlestick |
| ☐ Display Shift |
| ☐ Can Output NaN or ±Inf |
| ☐ Identity at Period 1 |
| ✅ Uses Transcendental i |
| ☐ Input Must Be Positive |
Example
#include <stdio.h>
#include <ta_libc.h>
int n = 252;
double series[252]; /* your data, oldest first */
double inPhase[252], quadrature[252];
int outBegIdx, outNBElement;
TA_Initialize();
TA_HT_PHASOR( 0, n - 1, series, &outBegIdx, &outNBElement, inPhase, quadrature );
printf( "%d values from bar %d:\n", outNBElement, outBegIdx );
printf( "inPhase = [%.4f, ..., %.4f]\n", inPhase[0], inPhase[outNBElement - 1] );
printf( "quadrature = [%.4f, ..., %.4f]\n", quadrature[0], quadrature[outNBElement - 1] );use ta_lib::Core;
let series = vec![0.0; 252]; // your data, oldest first
let mut in_phase = vec![0.0; 252];
let mut quadrature = vec![0.0; 252];
let core = Core::new();
let range = core.ht_phasor(0, series.len() - 1, &series, &mut in_phase, &mut quadrature)?;
println!("{} values from bar {}:", range.count, range.beg_idx);
println!("in_phase = [{:.4}, ..., {:.4}]", in_phase[0], in_phase[range.count - 1]);
println!("quadrature = [{:.4}, ..., {:.4}]", quadrature[0], quadrature[range.count - 1]);import io.github.talib.Core;
import io.github.talib.OutRange;
import java.util.Locale;
double[] series = new double[252]; // your data, oldest first
double[] inPhase = new double[252];
double[] quadrature = new double[252];
Core core = Core.DEFAULT;
OutRange r = core.htPhasor(0, series.length - 1, series, inPhase, quadrature);
System.out.printf(Locale.ROOT, "%d values from bar %d:%n", r.count(), r.begIdx());
System.out.printf(Locale.ROOT, "inPhase = [%.4f, ..., %.4f]%n", inPhase[0], inPhase[r.count() - 1]);
System.out.printf(Locale.ROOT, "quadrature = [%.4f, ..., %.4f]%n", quadrature[0], quadrature[r.count() - 1]);using System;
using TALib;
var series = new double[252]; // your data, oldest first
var inPhase = new double[252];
var quadrature = new double[252];
var core = Core.Default;
OutRange r = core.HtPhasor(0, series.Length - 1, series, inPhase, quadrature);
Console.WriteLine($"{r.Count} values from bar {r.BegIdx}:");
Console.WriteLine(FormattableString.Invariant($"inPhase = [{inPhase[0]:F4}, ..., {inPhase[r.Count - 1]:F4}]"));
Console.WriteLine(FormattableString.Invariant($"quadrature = [{quadrature[0]:F4}, ..., {quadrature[r.Count - 1]:F4}]"));import { htPhasor } from 'ta-lib';
const series = new Float64Array(252); // your data, oldest first
const { begIdx, outInPhase, outQuadrature } = htPhasor(series);
console.log(outInPhase.length + ' values from bar ' + begIdx + ':');
console.log('outInPhase = [' + outInPhase[0].toFixed(4) + ', ..., ' + outInPhase[outInPhase.length - 1].toFixed(4) + ']');
console.log('outQuadrature = [' + outQuadrature[0].toFixed(4) + ', ..., ' + outQuadrature[outQuadrature.length - 1].toFixed(4) + ']');import (
"fmt"
"log"
talib "ta-lib.github.io/go"
)
series := make([]float64, 252) // your data, oldest first
inPhase := make([]float64, 252)
quadrature := make([]float64, 252)
core := talib.NewCore()
r, err := core.HT_PHASOR(0, len(series)-1, series, inPhase, quadrature)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%d values from bar %d:\n", r.NBElement, r.BegIdx)
fmt.Printf("inPhase = [%.4f, ..., %.4f]\n", inPhase[0], inPhase[r.NBElement-1])
fmt.Printf("quadrature = [%.4f, ..., %.4f]\n", quadrature[0], quadrature[r.NBElement-1])Implementation
Added in 0.4.0.
TA-Lib Definition: ht_phasor.c · ht_phasor.yaml
| Native | File |
|---|---|
| C | ta_HT_PHASOR.c |
| Rust | ht_phasor.rs |
| Java | Core_HT_PHASOR.java |
| C# | Core_HT_PHASOR.cs |
| TypeScript | htPhasor.ts |
| Go | ht_phasor.go |
Python: talib.HT_PHASOR, see ta-lib-python.
TA-Lib is also available for R and more using a wrapper.
Aliases
Hilbert Transform Phasor, InPhase Quadrature
See Also
HT_DCPERIOD · HT_DCPHASE · HT_SINE · HT_TRENDMODE · MAMA · WMA
References
- John F. Ehlers, Rocket Science for Traders: Digital Signal Processing Applications, John Wiley & Sons (ISBN 0471405671)