- dm(high, low, length=None, mamode=None, talib=None, drift=None, offset=None, **kwargs)[source]#
Directional Movement (DM)
The Directional Movement was developed by J. Welles Wilder in 1978 attempts to determine which direction the price of an asset is moving. It compares prior highs and lows to yield to two series +DM and -DM.
- Default Inputs:
- length=14, mamode=”rma”, drift=1
up = high - high.shift(drift)
dn = low.shift(drift) - low
pos_ = ((up > dn) & (up > 0)) * up neg_ = ((dn > up) & (dn > 0)) * dn
pos_ = pos_.apply(zero) neg_ = neg_.apply(zero)
# Not the same values as TA Lib’s -+DM pos = ma(mamode, pos_, length=length) neg = ma(mamode, neg_, length=length)
high (pd.Series): Series of ‘high’s low (pd.Series): Series of ‘low’s mamode (str): See
`help(ta.ma)`. Default: ‘rma’ talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
version. Default: True
drift (int): The difference period. Default: 1 offset (int): How many periods to offset the result. Default: 0
pd.DataFrame: DMP (+DM) and DMN (-DM) columns.