Last active
July 31, 2021 18:11
-
-
Save mouchh/b236f6a3a75b6a216b10e6fc44cf090f to your computer and use it in GitHub Desktop.
Compute RSI stochastic from OHLC dataframe which give the same value as Trading View Stoch RSI(3, 3, 14, 14, close)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I was not able to retrieve same results as Trading View with talib STOCHRSI function... | |
# I may misuse talib params but I found it easier to rewrite the computation, following Trading View doc | |
# https://www.tradingview.com/support/solutions/43000502333-stochastic-rsi-stoch-rsi/ | |
# watchout on your params ;) | |
rsi = ta.RSI(dataframe) | |
stochrsi = 100 * (rsi - rsi.rolling(14).min()) / (rsi.rolling(14).max() - rsi.rolling(14).min()) | |
dataframe['stochrsi_fastk'] = stochrsi.rolling(3).mean() | |
dataframe['stochrsi_fastd'] = dataframe['stochrsi_fastk'].rolling(3).mean() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is so confusing as you are equating ta.RSI which is not a dataframe into using dataframe functions.