MINMAXINDEX indicator
MINMAXINDEX returns the indexes of the lowest and highest values over a specified period.
Method
tm.ta.minmaxindex(source, timeperiod)
Inputs
Parameter | Argument type | Description | Default Value |
---|---|---|---|
source | pd.Series | Input data series | - |
timeperiod | int | Number of periods for the indicator | 30 |
Outputs
The outputs are returned as a tuple of objects. Make sure to unpack them as shown in the example usage.
Output | Type |
---|---|
minidx | np.ndarray |
maxidx | np.ndarray |
Example usage
import tradomate as tm
@tm.strategy()def my_strategy(config: tm.TradomateConfig, data: tm.TradomateData):
# Trying out Indexes of lowest and highest values over a specified period minidx, maxidx = tm.ta.minmaxindex(data.close, timeperiod=30)
# Get the last value and print last_value = minidx.iloc[-1] tm.log(f"Last value of Indexes of lowest and highest values over a specified period is {last_value}")
# Plot the values of minidx tm.plot(minidx, title="Indexes of lowest and highest values over a specified period", overlay=False)