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

Re: EMA indicator calculation #632

Open
akaulgud1 opened this issue Jan 2, 2024 · 1 comment
Open

Re: EMA indicator calculation #632

akaulgud1 opened this issue Jan 2, 2024 · 1 comment

Comments

@akaulgud1
Copy link

Hello,

I have installed TA-LIB for Python.

I calculated EMA for 5 and 50 period against 6 months and 1 year data.

Couple of observations:

  1. value for 50EMA differs when I use 6 months data v/s 1 year data
  2. when compared with 50 EMA on investing.com, 50 ema calculated is not accurate , deviates by 10-12 points on higher side.

could you please look into this and advise.

Here is the code
5-50-setup.txt

Here are data files
RELIANCE-updated-using-1year-data.xlsx
RELIANCE-updated-using-6-months-data.csv

@mario4tier
Copy link
Member

mario4tier commented Nov 17, 2024

This is expected.

With the EMA algo, each new EMA uses the previous EMA. The function is in a sense "recursive". Depending how many previous data were fed to the function, the output will vary.

It is quite common for users to get confuse by this, and the EMA (and many algo using EMA) from many website/app do not disclose how they handle this. Many generally just assume that a popular website has to be "correct".

In the case of TA-Lib, there is a feature (named "unstable period") that allows devs to reduce (and control) such variance. The variance progressively reduce as there is more output... so the trick is for the function to start outputing only after the variance is "reasonably" low.

This is a complex subject, will let you digest this for a while, may be starting with understanding why EMA is "unstable" 😄

====

If this is too complicated, then just feed to the function as much input that you have... and accept that when you provide less input, the output will have a lot of variance in the first few outputs (and it gets more consistent as there is more output produced).

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

No branches or pull requests

2 participants