RSI is implemented according Perry Kaufman "Trading System and Methods" chapter 6 "Momentum and Oscillators".
The pseudo code:
Code:
sumup := 0
sumdown : = 0
for i = 1 to n begin
if close[i + 1] - close[i] > 0 then
sumup := sumup + close[i + 1] - close[i];
else sumdown := sumdown + close[i] - close[i + 1];
end;
end;
RSI = 100 - (100 / (1 + sumup / sumdown));