Skip to content

Double Exponential Moving Average

DEMA is a smoother moving average that reacts quickly to price changes.

Method

tm.ta.dema(source, timeperiod)

Inputs

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

Outputs

OutputType
demanp.ndarray

Example usage

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