Calculate wilders RSI2 manually

I am trying to calculate the 2-period RSI manually. Something seem to be wrong with my formula..

a1=ref(C,-1)-ref(C,-2);
a2=C-ref(C,-1);

b1=IIf(a1>0,a1,0);
b2=iIf(a2>0,a2,0);

c1=IIf(a1<0,0-a1,0);
c2=IIf(a2<0,0-a2,0);

c3=(b1+b2)/2;
c4=(c1+c2)/2;

e1=c3/c4;

RSI=iif(c4==0,100,100-(100/1+e1));

Each value of RSI is dependent on the values that have come before. If you really want to calculate it yourself, you would need to:

  1. Actually use the correct formula, which is available all over the internet
  2. Calculate the values in a loop
2 Likes