Exponential Moving Average
EMA gives more weight to recent prices, reflecting the latest market trends.
Method
tm.ta.ema(source, timeperiod)
Inputs
Parameter | Argument type | Description | Default Value |
---|---|---|---|
source | pd.Series | Input data series | - |
timeperiod | int | Number of periods for the indicator | 30 |
Outputs
Output | Type |
---|---|
ema | np.ndarray |
Example usage
import tradomate as tm
@tm.strategy()def my_strategy(config: tm.TradomateConfig, data: tm.TradomateData):
# Trying out Exponential Moving Average ema = tm.ta.ema(data.close, timeperiod=30)
# Get the last value and print last_value = ema.iloc[-1] tm.log(f"Last value of Exponential Moving Average is {last_value}")
# Plot the values of ema tm.plot(ema, title="Exponential Moving Average", overlay=False)