Skip to content

Index of highest value over a specified period

MAXINDEX returns the index of the highest value over a specified period.

Method

tm.ta.maxindex(source, timeperiod)

Inputs

ParameterArgument typeDescriptionDefault Value
sourcepd.SeriesInput data series-
timeperiodintNumber of periods for the indicator30

Outputs

OutputType
maxindexnp.ndarray

Example usage

strategy.py
import tradomate as tm
@tm.strategy()
def my_strategy(config: tm.TradomateConfig, data: tm.TradomateData):
# Trying out Index of highest value over a specified period
maxindex = tm.ta.maxindex(data.close, timeperiod=30)
# Get the last value and print
last_value = maxindex.iloc[-1]
tm.log(f"Last value of Index of highest value over a specified period is {last_value}")
# Plot the values of maxindex
tm.plot(maxindex, title="Index of highest value over a specified period", overlay=False)