Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the zema written here is actually DEMA #356

Merged
merged 4 commits into from
Aug 11, 2023
Merged

the zema written here is actually DEMA #356

merged 4 commits into from
Aug 11, 2023

Conversation

stash86
Copy link
Contributor

@stash86 stash86 commented Aug 7, 2023

remove zema, and use ta-lib DEMA

@xmatthias
Copy link
Member

Is this removal due to the tests you've been doing about the difference between running that indicator against a small vs. a big dataframe?

I'm not against that if that's the reason - just would want some clarity. (it's also used in another function - so right now, everything is broken ...)

@stash86
Copy link
Contributor Author

stash86 commented Aug 8, 2023

yes, I first noticed it when I do the recursive test. The difference of DEMA and this zema are identical for all lengths. So I checked investopedia for DEMA's formula, and found that current zema is actually DEMA

https://www.investopedia.com/ask/answers/121814/what-double-exponential-moving-average-dema-formula-and-how-it-calculated.asp

@xmatthias
Copy link
Member

xmatthias commented Aug 8, 2023

I'm not sure that's actually the case though (please read to the end - zema is still not correct).

the formula according to your link is DEMA=(2∗EMA(n))−(EMA(EMA(n))) ...

the "2x" part is missing - and the signs are also different.

That said - i can't find a definition for zema matching the implementation, either.
the closes is probably wikipedia's zlema

image

Which is however NOT corresponding to the implementation at hand, which appears to be something random.
Perfectly fine with removing ... though we'll also need to remove other references (in indicators.py).

@stash86
Copy link
Contributor Author

stash86 commented Aug 8, 2023

It's the same actually.

dataframe["d"] = dataframe["ema1"] - dataframe["ema2"]
dataframe["zema"] = dataframe["ema1"] + dataframe["d"]

can be re-arranged into

dataframe["zema"] = dataframe["ema1"] + dataframe["ema1"] - dataframe["ema2"]
dataframe["zema"] = (2 * dataframe["ema1"]) - dataframe["ema2"]
dataframe["zema"] = (2 * dataframe["ema1"]) - ta.EMA(dataframe["ema1"])

@stash86
Copy link
Contributor Author

stash86 commented Aug 8, 2023

I'm gonna remove all references to zema and replace it wth dema

Copy link
Member

@xmatthias xmatthias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@xmatthias xmatthias merged commit efbdb9a into main Aug 11, 2023
18 checks passed
@stash86 stash86 deleted the stash86-patch-1 branch August 22, 2023 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants