MACD with controllable MA type
MACDEXT is an extended version of MACD allowing for different MA types.
Method
Section titled “Method”tm.ta.macdext(source, fastperiod, fastmatype, slowperiod, slowmatype, signalperiod, signalmatype)Inputs
Section titled “Inputs”| Parameter | Argument type | Description | Default Value |
|---|---|---|---|
| source | pd.Series | Input data series | - |
| fastperiod | int | Fast period for the indicator | 12 |
| fastmatype | int | Fast Moving Average type | 0 |
| slowperiod | int | Slow period for the indicator | 26 |
| slowmatype | int | Slow Moving Average type | 0 |
| signalperiod | int | Signal period for the indicator | 9 |
| signalmatype | int | Signal Moving Average type | 0 |
Outputs
Section titled “Outputs”| Output | Type |
|---|---|
| macd | np.ndarray |
| macdsignal | np.ndarray |
| macdhist | np.ndarray |
Example usage
Section titled “Example usage”import tradomate as tm
@tm.strategy()def my_strategy(config: tm.TradomateConfig, data: tm.TradomateData):
# Trying out MACD with controllable MA type macd, macdsignal, macdhist = tm.ta.macdext(data.close, fastperiod=12, fastmatype=0, slowperiod=26, slowmatype=0, signalperiod=9, signalmatype=0)
# Get the last value and print last_value = macd.iloc[-1] tm.log(f"Last value of MACD with controllable MA type is {last_value}")
# Plot the values of macd tm.plot(macd, title="MACD with controllable MA type", overlay=False)