Quote:
Originally Posted by Nikolay.Gekht
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));
|
thank you for the sample. I guess this is just for the first period.
For the next periods it seems that it calculates Avg as:
diff = source[period] - source[period - 1];
if (diff > 0) then
sump = diff;
else
sumn = -diff;
end
positive = (pos[period - 1] * (n - 1) + sump) / n;
negative = (neg[period - 1] * (n - 1) + sumn) / n;
This is what I found in RSI body. Is that right?