Skip to content

Momentum

MOM measures the rate of change in prices over a specified period.

Method

tm.ta.mom(source, timeperiod)

Inputs

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

Outputs

OutputType
momnp.ndarray

Example usage

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