2

I am doing technical analysis using talib in Go. But the result looks different compared to the Binance live result.

Technical Analysis: RSI, Stoch RSI, Boler band, and MACD. All are showing the wrong results only.

Binance Dashboard URL: https://www.binance.com/en-IN/trade/BNB_USDT?layout=pro


import (
  "log"
  "time"

  "github.com/markcheno/go-talib"
  "github.com/pdepip/go-binance/binance"
)

func main() {
  q := binance.KlineQuery{
      Symbol:   "BNBUSDT",
      Interval: "5m",
      Limit:    288,
  }

  client := binance.New("", "")

  for true {

      kline, _ := client.GetKlines(q)

      inputs := []float64{}
      for _, e := range kline {
          inputs = append(inputs, e.Close)
      }

      rsi := talib.Rsi(inputs, 14)
      log.Println("RSI : ", rsi[len(rsi)-1])

      slowk, slowd := talib.StochRsi(inputs, 14, 3, 3, talib.EMA)
      log.Printf("Stoch RSI : %v %v ", slowk[len(slowk)-1], slowd[len(slowd)-1])

      upper, middle, lower := talib.BBands(inputs, 5, 2, 2, talib.T3MA)
      log.Printf("BBands : %v %v %v ", upper[len(upper)-1], middle[len(middle)-1], lower[len(lower)-1])

      macd, signal, hist := talib.Macd(inputs, 12, 26, 9)
      log.Printf("Macd : %v %v %v ", macd[len(macd)-1], signal[len(signal)-1], hist[len(hist)-1])

      time.Sleep(5 * time.Second)
      log.Println("_________________________________")
      log.Println("")
  }

}
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
  • Have you seen this reply? https://stackoverflow.com/questions/68624378/binance-futures-not-match-with-python-binance-solved?noredirect=1#comment121303305_68624378 – truf Aug 13 '21 at 13:51
  • Actually, I tried with talib in Python the result matching with Binance, and the same set I tried in golang the result getting different. Thank you! – dinesh pazani Aug 14 '21 at 04:24
  • 1
    Well, I've taken a look into github.com/markcheno/go-talib and found out that that's not a wrapper of original C library (like in python), but "pure Go port ". It reimplementes TA-Lib functions (all?) in Go language. So it's basically a different library. And there are discussion in it's issues related to results mismatch with original library: https://github.com/markcheno/go-talib/issues/1 – truf Aug 14 '21 at 10:51
  • Okay, got your point. let me search talib origin wrapper in golang. Thanks a lot! – dinesh pazani Aug 14 '21 at 15:39

2 Answers2

0

First thing is you have to use 1000 candles to get the same values as Binance because the calcul is depend to the given serie, so when you pass 288 row you will get different values

Zea
  • 145
  • 1
  • 6
0

StochRsi use both close and low and high prices, but you only pass close prices, in StochRsi, the lowest price means lowest low price, not lowest close price and the highest price means highest high price. it's not candles number issue.

  • btw, binance's default stoch params is `14 1 3`. – LiesAuer Jul 08 '23 at 02:24
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 12 '23 at 18:51