*RSI* is very useful in equity not much for futures.
Inputs: Length(9);
Variables: Counter(0), DownAmt(0), UpAmt(0), UpSum(0), DownSum(0), UpAvg(0), DownAvg(0), RSI(0);
var : Dindex(0), PreUpAvg(0), preDownAvg(0);
if date <> date[1] then {
Dindex = dindex + 1;
PreUpAvg = UpAvg[1];
preDownAvg = DownAvg[1];
}
If CurrentBar > 1 AND Length > 0 Then {
UpAmt = dayClose(0)-dayClose(1);
If UpAmt >= 0 Then
DownAmt = 0;
Else {
DownAmt = -UpAmt;
UpAmt = 0;
}
if Dindex <=1 Then {
UpAvg = 1;
DownAvg = 1;
}
Else {
UpAvg = (PreUpAvg * (Length - 1) + UpAmt) / Length;
DownAvg = (preDownAvg * (Length - 1) + DownAmt) / Length;
}
}
If UpAvg + DownAvg <> 0 Then
RSI = 100 * UpAvg / (UpAvg + DownAvg);
Else
RSI = 0;
plot1(RSI,"RSI");
PlotBaseLine1(30, "기준선 30", gray);
PlotBaseLine2(70, "기준선 70", gray);
No comments:
Post a Comment