Hilbert Transform - SineWave (HT_SINE)
Summary
Hilbert Transform SineWave: derives the dominant-cycle phase from price and emits its sine plus a 45-degree-lead sine. The two curves cross near cycle turning points. outSine and outLeadSine crossing marks cycle turning points.
Chart
Chart metadata i
Outputs
outSine:line·positive·negativeoutLeadSine:dash_line·positive·negative
Inputs
inReal— Source price series
Outputs
outSine— Sine of the dominant-cycle phaseoutLeadSine— Sine of the phase advanced 45 degrees (lead)
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
C
#include <stdio.h>
#include <ta_libc.h>
int n = 252;
double series[252]; /* your data, oldest first */
double sine[252], leadSine[252];
int outBegIdx, outNBElement;
TA_Initialize();
TA_HT_SINE( 0, n - 1, series, &outBegIdx, &outNBElement, sine, leadSine );
printf( "%d values from bar %d; last sine = %f\n", outNBElement, outBegIdx, sine[outNBElement - 1] );Rust
use ta_lib::Core;
let series = vec![0.0; 252]; // your data, oldest first
let mut sine = vec![0.0; 252];
let mut lead_sine = vec![0.0; 252];
let core = Core::new();
let range = core.ht_sine(0, series.len() - 1, &series, &mut sine, &mut lead_sine)?;
println!("{} values from bar {}; last sine = {}", range.count, range.beg_idx, sine[range.count - 1]);Java
import io.github.talib.Core;
import io.github.talib.OutRange;
double[] series = new double[252]; // your data, oldest first
double[] sine = new double[252];
double[] leadSine = new double[252];
Core core = Core.DEFAULT;
OutRange r = core.htSine(0, series.length - 1, series, sine, leadSine);
System.out.println(r.count() + " values from bar " + r.begIdx() + "; last sine = " + sine[r.count() - 1]);C#
using System;
using TALib;
var series = new double[252]; // your data, oldest first
var sine = new double[252];
var leadSine = new double[252];
var core = Core.Default;
OutRange r = core.HtSine(0, series.Length - 1, series, sine, leadSine);
Console.WriteLine($"{r.Count} values from bar {r.BegIdx}; last sine = {sine[r.Count - 1]}");TypeScript
import { htSine } from 'ta-lib';
const series = new Float64Array(252); // your data, oldest first
const { begIdx, outSine, outLeadSine } = htSine(series);
console.log(outSine.length + ' values from bar ' + begIdx + '; last outSine = ' + outSine[outSine.length - 1]);Implementation
Added in 0.4.0.
TA-Lib Definition: ht_sine.c · ht_sine.yaml
| Native | File |
|---|---|
| C | ta_HT_SINE.c |
| Rust | ht_sine.rs |
| Java | Core_HT_SINE.java |
| C# | Core_HT_SINE.cs |
| TypeScript | htSine.ts |
Python: talib.HT_SINE, see ta-lib-python.
TA-Lib is also available for R and more using a wrapper.
Aliases
Hilbert Transform SineWave, Ehlers SineWave, SineWave Indicator
See Also
HT_DCPHASE · HT_DCPERIOD · HT_PHASOR · HT_TRENDMODE · MAMA
References
- John F. Ehlers, Rocket Science for Traders: Digital Signal Processing Applications, John Wiley & Sons (ISBN 0471405671)