markcheno / go-talib

A pure Go port of TA-Lib (http://ta-lib.org)
MIT License
763 stars 213 forks source link

Confused about RSI #16

Closed ydcool closed 4 years ago

ydcool commented 4 years ago

https://github.com/markcheno/go-talib/blob/cd53a9264d70bedcff891f59bf153275f524c100/talib.go#L2819-L2840

Hi Mark, just start reading this source codes, and got a little confused about the today variable in func Rsi, it seems that at L2840 the today will be 3 at least because there's an auto-increament operation at L2823 and min value of inTimePeriod is 2, so the else part at L2850 would never be reached. Is that right?

ydcool commented 4 years ago

I also read the RSI in c at https://sourceforge.net/p/ta-lib/code/HEAD/tree/trunk/ta-lib/c/src/ta_func/ta_RSI.c#l358 I'm not quite familar with c , just wonder that could the startIdx be simplified as 0?

markcheno commented 4 years ago

Hi Dominic, This code is a straight up port from the Java version of TA-Lib. So any peculiarities like that exist in the original version as well. Since I test the output of this version against the original TA-Lib, I'm inclined to leave it alone for now.

ydcool commented 4 years ago

I see. I have read the java version and finally figured it out. The reason that your code got the correct result is the last for loop coverd the caculations, and those dead codes above have no side effects.