TA-Lib / ta-lib-python

Python wrapper for TA-Lib (http://ta-lib.org/).
http://ta-lib.github.io/ta-lib-python
Other
9.49k stars 1.74k forks source link

the difference in EMA compared to TradingView #428

Closed pyed closed 3 years ago

pyed commented 3 years ago

consider the following code

import numpy as np
import yfinance as yf
import talib

msft = yf.Ticker("MSFT")
history = msft.history(period="6mo")
closes = np.asarray(history['Close'])

ema = talib.EMA(closes, timeperiod=100)

print(ema)

if you compare the results to TradingView's EMA of MSFT there'll be a noticeable difference, I noticed that the docs says the following about EMA: NOTE: The EMA function has an unstable period. but even on short periods you can notice the difference, how can we calculate EMA like TradingView ?

pyed commented 3 years ago

your history period and your TradingView's period should match to get a similar EMA