Skip to content

Hilbert Transform - Trend vs Cycle Mode

HT_TRENDMODE identifies whether the market is in a trending or cyclical mode.

Method

tm.ta.ht_trendmode(source)

Inputs

ParameterArgument typeDescriptionDefault Value
sourcepd.SeriesInput data series-

Outputs

OutputType
ht_trendmodenp.ndarray

Example usage

strategy.py
import tradomate as tm
@tm.strategy()
def my_strategy(config: tm.TradomateConfig, data: tm.TradomateData):
# Trying out Hilbert Transform - Trend vs Cycle Mode
ht_trendmode = tm.ta.ht_trendmode(data.close)
# Get the last value and print
last_value = ht_trendmode.iloc[-1]
tm.log(f"Last value of Hilbert Transform - Trend vs Cycle Mode is {last_value}")
# Plot the values of ht_trendmode
tm.plot(ht_trendmode, title="Hilbert Transform - Trend vs Cycle Mode", overlay=False)