From e6e5c5daf02a88fa875f5445c5fece13aaf109ef Mon Sep 17 00:00:00 2001 From: ran Date: Tue, 31 Oct 2017 21:58:03 +0200 Subject: [PATCH] added zlma --- freqtrade/vendor/qtpylib/indicators.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/freqtrade/vendor/qtpylib/indicators.py b/freqtrade/vendor/qtpylib/indicators.py index c4b955626..22fac4e2a 100644 --- a/freqtrade/vendor/qtpylib/indicators.py +++ b/freqtrade/vendor/qtpylib/indicators.py @@ -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") # ---------------------------------------------