twopirllc / pandas-ta

Technical Analysis Indicators - Pandas TA is an easy to use Python 3 Pandas Extension with 150+ Indicators
https://twopirllc.github.io/pandas-ta/
MIT License
5.21k stars 1.02k forks source link

Vidya indicator calculated results are not same as tradingview #545

Open Son-Sam opened 2 years ago

Son-Sam commented 2 years ago

**Which version are you running? The last version : (from python-dateutil>=2.8.1->pandas->pandas-ta==0.3.14b0)

Is your feature request related to a problem? Please describe. The result of vidya function ta.vidya(df["Close"],length=7).iloc[-1] not equal with tradingview vidya

Describe the solution you'd like Fix vidya indicator results to be same as tradingview please vidya indicator in tradingview(https://www.tradingview.com/script/hdrf0fXV-Variable-Index-Dynamic-Average-VIDYA/) is same as you mentioned source in your vidya.py with same timeframe, length but results are not match

Thanks

twopirllc commented 2 years ago

@A-Salimi-A,

A common issue is assuming ohlcv bars are the same among data sources (brokers, exchanges, Polygon, Alpaca, TV, et al), but that's not always true. So do you have the same ohlcv data, bar by bar, in your df as TV? In other words, did you manually export your data from TV and create your df from that or did you use another external source for the df? If your bars are not identical, then the data sources might as well be apples and oranges and thus deviations in results can occur like above.

Disclaimer I want to point out that this is not a TradingView (TV) library. They provide no support or funding nor do other creators (like Everget) on TV. So sometimes no matter how close the code is to TV or the author, there can be differences. 🤷🏼‍♂️

Lastly, this is primarily a TA Lib Python replacement (if TA Lib can not be installed). Do you have TA Lib installed also?

Kind Regards, KJ

Son-Sam commented 2 years ago

First thank for reply

I export data from tradingview and checked all of them by bar to bar. the data is as same as each other and completely match but results are not same in vidya indicator (ta.sma and ta.wma results are same as tradingview then we can interpret the source data is same)

ae

TA Lib not installed

twopirllc commented 2 years ago

@A-Salimi-A

I assume that is Everget's VIDYA column from TV script you linked above?

Please upload the csv here that you posted in the image.

Thanks, KJ

Son-Sam commented 2 years ago

@A-Salimi-A

I assume that is Everget's VIDYA column from TV script you linked above?

Please upload the csv here that you posted in the image.

Thanks, KJ

yeah that's TV Everget's VIDYA results that dont match with ta.vidya in pandas_ta

last 50 bars in csv file its begin from row 251

best regards

Son-Sam commented 2 years ago

aaa

Pandas_ta and tradingview setting for VIDYA is same length = 7

BINANCE_NEARUSDT, 60.csv

twopirllc commented 2 years ago

@A-Salimi-A,

That helps a lot. I'll get to when I can.

Thanks, KJ

Son-Sam commented 2 years ago

Dear @twopirllc

Hope this help to fix this issue:

pandas_ta vidya formula include vidya.iloc[i - 1] and this values are Nan or replaced with zero for first values vidya indicator in TV can calculate length for 1 period, but pandas_ta cant calculate for 1 period.

Best Regards

twopirllc commented 2 years ago

Hello @Son-Sam,

Thanks for chiming in! I don't quite get what you mean. Does this fix work? If so, could you please submit a Pull Request (PR). If not, please post share relevant code.

Kind Regards, KJ