Skip to content

MESA Adaptive Moving Average

MAMA is an adaptive moving average designed to capture trends in varying market conditions.

tm.ta.mama(source, fastlimit, slowlimit)
ParameterArgument typeDescriptionDefault Value
sourcepd.SeriesInput data series-
fastlimitfloatFast limit for the indicator0
slowlimitfloatSlow limit for the indicator0
OutputType
mamanp.ndarray
famanp.ndarray
strategy.py
import tradomate as tm
@tm.strategy()
def my_strategy(config: tm.TradomateConfig, data: tm.TradomateData):
# Trying out MESA Adaptive Moving Average
mama, fama = tm.ta.mama(data.close, fastlimit=0, slowlimit=0)
# Get the last value and print
last_value = mama.iloc[-1]
tm.log(f"Last value of MESA Adaptive Moving Average is {last_value}")
# Plot the values of mama
tm.plot(mama, title="MESA Adaptive Moving Average", overlay=False)