-
Notifications
You must be signed in to change notification settings - Fork 1k
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
SuperTrend values are not matching with Zerodha #819
Comments
Can you export some sample data from Zerodha after putting supertrend on the chart, so both OHLC and supertrend values are exported, and then try pandas-ta on the same OHLC values with both RMA and SMA mamode. If they still don't match, you can share the exported data here along with your code and I can take a look. |
Hi MLpranav, At some places values with sma are matching at some places values with rma are matching and some are not matching at all. i have used following code to generate files. |
RMA values are matching 09:53 onwards. Values before that differ because the Kite chart is also using previous days' data for supertrend calculation, but pandas-ta is getting only the current day's data. Theoretically supertrend(7, 3) requires only 7+1 candles to compute, but I have seen in practice that at least 10-15 times the number of candles should be given to get the most accurate result. This happens because supertrend formula gives value of both upper and lower band, and the current band depends on where has the price crossed the ST. And that usually falls beyond the 8 candle lookback period. |
@MLpranav, Thanks for the reply |
@MLpranav @twopirllc |
As mentioned before, you need to pass previous 2-3 days data as well to get matching values. Try to give around 100 candles. Zerodha is also using previous few days' data and not just 7 candles. |
Hi @MLpranav, BANKNIFTY AUG 51200 CE_ Zerodha.csv Today got horrible difference specially in between period 9.34 to 10.04 AM as attached in above files. Hi i have tried almost all possible things like -
In your post you mentioned that your ta ST(7,3) values started matching with zerodha after doing certain changes. Can you please try to calculate ST values with your code and attached data if those matches at your end? |
Hello @prashantrpatil @MLpranav Before you dig too far into the weeds of this, I recommend basing your decuctions on the development code and not version 0.3.14b. Second, this library is a complementary (or supplementary) to first TA Lib and second (where applicable) TV. However if anyone wants to include variations for blackboxed systems like Zerodha, ToS, Tradestation, et al, then by all means checkout the development branch, make an optional flag (like Third. Before I update the indicator, supertrend like other deep conditional based loop indicators, will need a numba version to boost performance. For an example numba implementation, see atrts. Unfortunately, this is the quickest and surest way to get the changes implemented into the library. Kind Regards, |
Zerodha offers two charting backends - TradingView and ChartIQ. I've gone down this rabbit hole a while back and can confirm that the current supertrend implementation is correct and perfectly matches with Zerodha. Two most common reasons for a discrepancy are - variation in the values of atr_mamode (Zerodha earlier used 'SMA' but now uses 'RMA' if I recall correctly) and more importantly, using a very short lookback window (passing 10-15x as many candles as the supertrend period is good enough in my experience). @prashantrpatil, do try passing at least past 1 whole day's data in addition to the current day and then check the values, if still not matching then try with past 2 or 3 days. Check with RMA (which is the default) and try SMA also if the values still don't match. If you are still unable to match the values, please share 3 entire days data and your complete code and I can take a look. |
pandas 2.2.2 and pandas_ta 0.3.14b0
Do you have TA Lib also installed in your environment?
No
Have you tried the development version? Did it resolve the issue?
No
Issue:
I am calculating super trend value using ta but my output is not matching with other platforms like Zerodha. And difference is not in decimal points here and there but it is huge.
What i have tried:
instead of rma tried to send sma as mamode while calculating ATR but still values are not matching.
The text was updated successfully, but these errors were encountered: