TAlib.Indicators.HT (TAlib v0.13.0)

Copy Markdown View Source

Hilbert-transform cycle indicators (TA-Lib Cycle Indicators group), translated from the TA-Lib C reference implementation of John Ehlers' MESA machinery ("Rocket Science for Traders").

Every function takes prices oldest first and returns series aligned with the input: the first 63 entries are nil (the fixed warmup of the 4-bar WMA pre-smoother and the Hilbert transformer). TA-Lib's configurable unstable-period machinery, which shifts where outputs begin, is not mirrored. See TAlib for the remaining conventions.

Summary

Functions

The Hilbert Transform - Dominant Cycle Period.

The Hilbert Transform - Dominant Cycle Phase, in degrees.

The Hilbert Transform - Phasor Components: the in-phase (I1) and quadrature (Q1) series, as a map.

The Hilbert Transform - SineWave: sine and lead_sine (45 degrees ahead), as a map.

The Hilbert Transform - Instantaneous Trendline: the raw price averaged over the dominant cycle and blended with its own recent values.

The Hilbert Transform - Trend vs Cycle Mode: 1 when the price is trending, 0 when it is cycling.

Functions

align(values)

core_stream(prices)

ht_dcperiod(prices)

@spec ht_dcperiod([number()]) :: [float() | nil]

The Hilbert Transform - Dominant Cycle Period.

iex> TAlib.Indicators.HT.ht_dcperiod(Enum.to_list(1..100)) |> List.last() |> Float.round(4)
42.5223

ht_dcphase(prices)

@spec ht_dcphase([number()]) :: [float() | nil]

The Hilbert Transform - Dominant Cycle Phase, in degrees.

iex> TAlib.Indicators.HT.ht_dcphase(Enum.to_list(1..100)) |> List.last() |> Float.round(4)
183.9149

ht_phasor(prices)

@spec ht_phasor([number()]) :: %{
  inphase: [float() | nil],
  quadrature: [float() | nil]
}

The Hilbert Transform - Phasor Components: the in-phase (I1) and quadrature (Q1) series, as a map.

iex> values = TAlib.Indicators.HT.ht_phasor(Enum.to_list(1..100))
iex> Float.round(List.last(values.quadrature), 4)
-1.9195

ht_sine(prices)

@spec ht_sine([number()]) :: %{sine: [float() | nil], lead_sine: [float() | nil]}

The Hilbert Transform - SineWave: sine and lead_sine (45 degrees ahead), as a map.

iex> values = TAlib.Indicators.HT.ht_sine(Enum.to_list(1..100))
iex> Float.round(List.last(values.sine), 4)
-0.0683

ht_trendline(prices)

@spec ht_trendline([number()]) :: [float() | nil]

The Hilbert Transform - Instantaneous Trendline: the raw price averaged over the dominant cycle and blended with its own recent values.

iex> TAlib.Indicators.HT.ht_trendline(Enum.to_list(1..100)) |> List.last() |> Float.round(4)
76.85

ht_trendmode(prices)

@spec ht_trendmode([number()]) :: [0 | 1 | nil]

The Hilbert Transform - Trend vs Cycle Mode: 1 when the price is trending, 0 when it is cycling.

iex> TAlib.Indicators.HT.ht_trendmode(Enum.to_list(1..100)) |> List.last()
1

scan(stream, tail, step)