MESA Adaptive Moving Average
MAMA is an adaptive moving average designed to capture trends in varying market conditions.
Method
tm.ta.mama(source, fastlimit, slowlimit)
Inputs
Parameter | Argument type | Description | Default Value |
---|---|---|---|
source | pd.Series | Input data series | - |
fastlimit | float | Fast limit for the indicator | 0 |
slowlimit | float | Slow limit for the indicator | 0 |
Outputs
The outputs are returned as a tuple of objects. Make sure to unpack them as shown in the example usage.
Output | Type |
---|---|
mama | np.ndarray |
fama | np.ndarray |
Example usage
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)