Skip to content

Relative Strength Index

RSI measures the speed and change of price movements.

Method

tm.ta.rsi(source, timeperiod)

Inputs

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

Outputs

OutputType
rsinp.ndarray

Example usage

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