Hello All
I'm trying to calculate rolling RSI (which is a financial indicate), I found this code, it should help me do the calculation. However, I'm very understand what is this piece of code doing. Would you please explain the code line by line, so that I can do the necessary changes to solve my case.
%macro calRSI();
%do i=16 %to 7570;
data RSI;
set RSI;
lAveGain = lag1(AveGain);
lAveLoss = lag1(AveLoss);
if days = &i then do;
AveGain = (lAveGain*13+gain)/14;
AveLoss = (lAveLoss*13+loss)/14;
RS = AveGain / AveLoss;
RSI = 100-100/(1+RS); end;
%end; %mend;
%calRSI;
data summer.RSIresult;
set RSI; run;