Skip to content

Stochastic Relative Strength Index

STOCHRSI combines elements of Stochastic and RSI to identify overbought and oversold conditions.

Method

tm.ta.stochrsi(source, timeperiod, fastk_period, fastd_period, fastd_matype)

Inputs

ParameterArgument typeDescriptionDefault Value
sourcepd.SeriesInput data series-
timeperiodintNumber of periods for the indicator14
fastk_periodintFast %K period for the indicator5
fastd_periodintFast %D period for the indicator3
fastd_matypeintFast %D Moving Average type0

Outputs

OutputType
fastknp.ndarray
fastdnp.ndarray

Example usage

strategy.py
import tradomate as tm
@tm.strategy()
def my_strategy(config: tm.TradomateConfig, data: tm.TradomateData):
# Trying out Stochastic Relative Strength Index
fastk, fastd = tm.ta.stochrsi(data.close, timeperiod=14, fastk_period=5, fastd_period=3, fastd_matype=0)
# Get the last value and print
last_value = fastk.iloc[-1]
tm.log(f"Last value of Stochastic Relative Strength Index is {last_value}")
# Plot the values of fastk
tm.plot(fastk, title="Stochastic Relative Strength Index", overlay=False)