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
Parameter | Argument type | Description | Default Value |
---|---|---|---|
source | pd.Series | Input data series | - |
timeperiod | int | Number of periods for the indicator | 14 |
fastk_period | int | Fast %K period for the indicator | 5 |
fastd_period | int | Fast %D period for the indicator | 3 |
fastd_matype | int | Fast %D Moving Average type | 0 |
Outputs
The outputs are returned as a tuple of objects. Make sure to unpack them as shown in the example usage.
Output | Type |
---|---|
fastk | np.ndarray |
fastd | np.ndarray |
Example usage
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)