added zlma

This commit is contained in:
ran 2017-10-31 21:58:03 +02:00 committed by gcarq
parent 61f92b7460
commit e6e5c5daf0

View File

@ -552,6 +552,26 @@ def stoch(df, window=14, d=3, k=3, fast=False):
return pd.DataFrame(index=df.index, data=data)
# ---------------------------------------------
def zlma(series, window=20, kind="ema"):
"""
John Ehlers' Zero lag (exponential) moving average
https://en.wikipedia.org/wiki/Zero_lag_exponential_moving_average
"""
lag = (window - 1) // 2
series = 2 * series - series.shift(lag)
if kind in ['ewm', 'ema']:
return ema(series, lag)
elif kind == "hma":
return hma(series, lag)
return sma(series, lag)
def zlema(series, window):
return zlma(series, window, kind="ema")
def zlsma(series, window):
return zlma(series, window, kind="sma")
def zlhma(series, window):
return zlma(series, window, kind="hma")
# ---------------------------------------------