I'm trying to calculate the rsi on historical bitcoin data and chart it out
I wrote the code myself, I have the issue what do I do if the averg loss is zero so I have
rs=averg gain/0, whith is infinty?
I know, this does not answer your question.
But, beside the learning effect for doing so, why don't you use a tool like ta-lib for this? ta-lib supports tremendous amount of signals, indicators, trend indicator and even candle stick patterns. There are lib implementations for nearly every language like NodeJS, Java, C++, C#, Python, etc.
Hope that helps,
alex