bukosabino/ta

Please help: macd_signal and stochrsi different to Tradingview (Bitmex)

BruceBushby opened this issue · 1 comments

Hi

Great library thank you! I'm hoping the community can assist with a couple of issues.

Documents: https://readthedocs.org/projects/technical-analysis-library-in-python/downloads/pdf/latest/

My goal is to match the indicator values available via Tradingview.

For the most part, Stoch, RSI, Willr & CCI are perfect to four decimal places, sadly I cannot for the life of me get correct values for "macd signal" ... macd however is correct to four decimal places.

For testing I use this chart: https://www.bitmex.com/chartEmbed?symbol=XBTUSD

Code snippet to replicate results:

|
|
|
|

#!/usr/bin/env python

import sys
import datetime
from bitmex import bitmex
import ta as ta
import pandas as pd
from ta import add_all_ta_features
from ta.utils import dropna
import talib
from talib import MA_Type

count = 1000

period = "1m"
starttime = datetime.datetime.now() - datetime.timedelta(minutes=count)

bitmex_client = bitmex(test=False)

get 1m candles

df = bitmex_client.Trade.Trade_getBucketed(symbol='XBTUSD', binSize=period, count=count, startTime=starttime).result()[0]
df = pd.DataFrame(df, columns=['timestamp','open','high','low','close','volume'])
df.set_index('timestamp', inplace=True)

df = ta.add_all_ta_features(df, open="open", high="high", low="low", close="close", volume="volume")

add selected columns

idf = df[['open','high','low','close','volume','trend_macd','trend_macd_signal','momentum_stoch_rsi_k','momentum_stoch_rsi_d','momentum_stoch','momentum_stoch_signal','momentum_rsi']]

rename columns

idf.rename(columns={'trend_macd':'macd','trend_macd_signal':'macds','momentum_stoch_rsi_k':'stochrsik','momentum_stoch_rsi_d':'stochrsid','momentum_stoch':'stochk','momentum_stoch_signal':'stochd','momentum_rsi':'rsi'}, inplace=True)

reorder columns

idf = idf[['open','high','low','close','volume','macd','macds','stochrsik','stochrsid','stochk','stochd','rsi']]

print(idf.round(decimals=4))

|
|
|
|

The following pic shows the output at the bottom and compares values to those available via Tradingview:

ta-example-results

macd, stoch & rsi are perfect to four decimal places ..... however macd signal remains different.

stochrsi is also different,

Any help or advice would be MUCH appreciated.

Thanks

Closing issue, not a "ta" problem. Looks like Tradingview calculates macd_signal using SMA.

Possible TradingView StochRSI is calculated from "rsi" values.