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; last inPhase = %f\n", outNBElement, outBegIdx, inPhase[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 {}; last in_phase = {}", range.count, range.beg_idx, in_phase[range.count - 1]);import io.github.talib.Core;
import io.github.talib.OutRange;
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.println(r.count() + " values from bar " + r.begIdx() + "; last inPhase = " + inPhase[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}; last inPhase = {inPhase[r.Count - 1]}");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 + '; last outInPhase = ' + outInPhase[outInPhase.length - 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 |
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)