함수설명
RSI(Relative Strength Index) 지표함수
※기존 RSI함수는 기간만 지정이 가능하고 계산의 기준값은 지정할 수 없었지만
RSI_TA함수는 기준값을 다른 값으로 지정해 계산할 수 있습니다.
작성방법
RSI_TA(기준값, 기간)
C
복사
매개변수 설명
•
"기준값": Numeric, 데이터, 함수, 변수, 계산식 등
•
"기간": Numeric, 최근 N개봉 기간값을 입력
계산
A1 = N기간 상승폭의 합계
B1 = N기간 하락폭의 합계
RSI = A1/(A1+B1)*100
활용예시
1.
var1 = RSI(ma(c,5), 10); --> 5기간 단순이동평균으로 RSI값을 계산하고 var1에 저장
2.
//인라인함수(수식안에서 만들어 사용하는 함수)
Function infx_RSI_TA Numeric
{
Inputs: Price(NumericSeries), Length(NumericSimple);
Variables: Counter(0), DownAmt(0), UpAmt(0), UpSum(0), DownSum(0), UpAvg(0), DownAvg(0);
If CurrentBar == 1 AND Length > 0 Then Begin
UpSum = 0;
DownSum = 0;
For Counter = 0 To Length - 1 Begin
UpAmt = Price[Counter] - Price[Counter+1];
If UpAmt >= 0 Then
DownAmt = 0;
Else Begin
DownAmt = -UpAmt;
UpAmt = 0;
End;
UpSum = UpSum + UpAmt;
DownSum = DownSum + DownAmt;
End;
UpAvg = UpSum / Length;
DownAvg = DownSum / Length;
End
Else
If CurrentBar > 1 AND Length > 0 Then Begin
UpAmt = Price[0] - Price[1];
If UpAmt >= 0 Then
DownAmt = 0;
Else Begin
DownAmt = -UpAmt;
UpAmt = 0;
End;
UpAvg = (UpAvg[1] * (Length - 1) + UpAmt) / Length;
DownAvg = (DownAvg[1] * (Length - 1) + DownAmt) / Length;
End;
If UpAvg + DownAvg <> 0 Then
infx_RSI_TA = 100 * UpAvg / (UpAvg + DownAvg);
Else
infx_RSI_TA = 0;
}
EndFunction
input : Period(10);
value1 = ma(C,5);
var1 = infx_RSI_TA(value1,Period);
Plot1(var1,"RSI");
PlotBaseLine1(30, "기준선 30");
PlotBaseLine2(70, "기준선 70");
C
복사
뒤로가기는 좌측상단의 목차 버튼을 눌러주세요.