예스스탁
예스스탁 답변
2022-10-28 15:06:12
안녕하세요
예스스탁입니다.
Input : 타주기분(15), RSIPeriod(14),Period(14),K(3),D(3);
input : short(12),long(26),sig(9);
var : cnt(0),S1(0),D1(0),TM(0),TF(0);
var : SigSum(0),count2(0),RSIsig(0);
Var : Counter(0), DownAmt(0), UpAmt(0), UpSum(0), DownSum(0), UpAvg(0), DownAvg(0);
var : idx(0), PreUpAvg(0), preDownAvg(0),HH(0),LL(0),sum1(0),sum2(0);
var : EP1(0),EP2(0),EP3(0);
var : xma1(0),xma2(0),Prexma1(0),Prexma2(0),MACDV(0),MACDS(0),PreMACDS(0),MACDO(0);
var : RSI1(0),SR(0),SK(0),sd(0);
Array : C1[100](0),RSIV[100](-1),StoRsi[100](-1),Stok[100](-1),StoD[100](-1);
Ep1 = 2/(short+1);
Ep2 = 2/(long+1);
Ep3 = 2/(sig+1);
RSI1 = RSI(RSIPeriod);
SR = (RSI1- lowest(RSI1,Period)) / ( highest(RSI1,Period)-lowest(RSI1,Period) ) *100 ;
SK = ma(RSI1,K);
SD = ma(SK,D);
if Bdate != Bdate[1] Then
{
S1 = TimeToMinutes(stime);
D1 = sdate;
}
if D1 > 0 then
{
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1;
Else
TM = TimeToMinutes(stime)+1440-S1;
TF = TM%타주기분;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and 타주기분 > 1 and TF < TF[1]) or
(Bdate == Bdate[1] and 타주기분 > 1 and TM >= TM[1]+타주기분) or
(Bdate == Bdate[1] and 타주기분 == 1 and TM > TM[1]) Then
{
for cnt = 1 to 99
{
C1[cnt] = C1[cnt-1][1];
RSIv[cnt] = RSIv[cnt-1][1];
StoRsi[cnt] = StoRsi[cnt-1][1];
Stok[cnt] = Stok[cnt-1][1];
Stod[cnt] = Stod[cnt-1][1];
}
PreUpAvg = UpAvg[1];
preDownAvg = DownAvg[1];
idx = idx + 1;
}
C1[0] = C;
if idx <= 1 then
{
xma1 = C;
xma2 = C;
MACDV = xma1-xma2;
MACDS = MACDV;
MACDO = MACDV-MACDS;
}
else{
xma1 = C * EP1 + Prexma1 * (1-EP1);
xma2 = C * EP2 + Prexma2 * (1-EP2);
MACDV = xma1-xma2;
MACDS = MACDV * EP3 + PreMACDS * (1-EP3);
MACDO = MACDV-MACDS;
}
If idx == RSIPeriod+2 Then
{
UpSum = 0;
DownSum = 0;
For Counter = 0 To RSIPeriod - 1 {
UpAmt = C1[Counter] - C1[Counter+1];
If UpAmt >= 0 Then
DownAmt = 0;
Else{
DownAmt = -UpAmt;
UpAmt = 0;
}
UpSum = UpSum + UpAmt;
DownSum = DownSum + DownAmt;
}
UpAvg = UpSum / RSIPeriod;
DownAvg = DownSum / RSIPeriod;
}
If idx > RSIPeriod+2 Then {
UpAmt = C1[0] - C1[1];
If UpAmt >= 0 Then
DownAmt = 0;
Else {
DownAmt = -UpAmt;
UpAmt = 0;
}
UpAvg = (PreUpAvg * (RSIPeriod - 1) + UpAmt) / RSIPeriod;
DownAvg = (preDownAvg * (RSIPeriod - 1) + DownAmt) / RSIPeriod;
}
If UpAvg + DownAvg <> 0 Then
RSIv[0] = 100 * UpAvg / (UpAvg + DownAvg);
Else
RSIv[0] = 0;
if RSIV[Period-1] >= 0 Then
{
hh = RSIV[0];
LL = RSIV[0];
For cnt = 0 to Period-1
{
if RSIV[cnt] > hh Then
hh = RSIV[cnt];
if RSIV[cnt] < ll Then
ll = RSIV[cnt];
}
StoRsi[0] = (RSIv[0]- LL) / (HH-LL) *100 ;
}
if StoRsi[K-1] >= 0 Then
{
sum1 = 0;
For cnt = 0 to K-1
{
sum1 = sum1 + StoRsi[cnt];
}
stok[0] = sum1/K;
}
if Stok[D-1] >= 0 Then
{
sum2 = 0;
For cnt = 0 to D-1
{
sum2 = sum2 + StoK[cnt];
}
stod[0] = sum2/d;
}
if macdo > 0 and
rsiv[0] > 50 and //rsi가 storsi이면 StoRsi[0] > 50
stok[0] > 50 and
CrossUp(sk,sd) Then
Buy();
}
즐거운 하루되세요
> 당일선물 님이 쓴 글입니다.
> 제목 : 79357 번 수식의뢰 에서
> 작성해주신 수식에서
스토캐스틱RSI 값이
79310번 글에서 요청하여 작성해주신 수식의 값과 다른데
타주스스토캐스틱RSI(14,3,3) 와
현 설정챠트 스토캐스틱RSI(14,3,3) 동일수식 변수입니다.
수정부탁드립니다
사용자함수로 StoRsi StoK StoD 를 작성해두었으니 참고 바랍니다.
/////////////
input : RSIPeriod(NumericSimple),Period(NumericSimple),K(NumericSimple),D(NumericSimple);
var : RSIV(0);
RSIv = RSI(RSIPeriod);
StoRsi = (RSIv- lowest(RSIv,Period)) / ( highest(RSIv,Period)-lowest(RSIv,Period) ) *100 ;
///////////
input : RSIPeriod(NumericSimple),Period(NumericSimple),K(NumericSimple),D(NumericSimple);
var : RSIV(0),StoRsi(0);
RSIv = RSI(RSIPeriod);
StoRsi = (RSIv- lowest(RSIv,Period)) / ( highest(RSIv,Period)-lowest(RSIv,Period) ) *100 ;
StoK = ma(StoRsi,K);
//////////////
input : RSIPeriod(NumericSimple),Period(NumericSimple),K(NumericSimple),D(NumericSimple);
var : RSIV(0),StoRsi(0),StoK(0);
RSIv = RSI(RSIPeriod);
StoRsi = (RSIv- lowest(RSIv,Period)) / ( highest(RSIv,Period)-lowest(RSIv,Period) ) *100 ;
StoK = ma(StoRsi,K);
StoD = ma(StoK,D);
//////////////////
===========
안녕하세요
예스스탁입니다.
Input : 타주기분(15), RSIPeriod(14),Period(14),K(3),D(3);
var : cnt(0),S1(0),D1(0),TM(0),TF(0);
var : SigSum(0),count2(0),RSIsig(0);
Var : Counter(0), DownAmt(0), UpAmt(0), UpSum(0), DownSum(0), UpAvg(0), DownAvg(0);
var : idx(0), PreUpAvg(0), preDownAvg(0),HH(0),LL(0),sum1(0),sum2(0);
Array : C1[100](0),RSIV[100](-1),StoRsi[100](-1),Stok[100](-1),StoD[100](-1);
if Bdate != Bdate[1] Then
{
S1 = TimeToMinutes(stime);
D1 = sdate;
}
if D1 > 0 then
{
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1;
Else
TM = TimeToMinutes(stime)+1440-S1;
TF = TM%타주기분;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and 타주기분 > 1 and TF < TF[1]) or
(Bdate == Bdate[1] and 타주기분 > 1 and TM >= TM[1]+타주기분) or
(Bdate == Bdate[1] and 타주기분 == 1 and TM > TM[1]) Then
{
for cnt = 1 to 99
{
C1[cnt] = C1[cnt-1][1];
RSIv[cnt] = RSIv[cnt-1][1];
StoRsi[cnt] = StoRsi[cnt-1][1];
Stok[cnt] = Stok[cnt-1][1];
Stod[cnt] = Stod[cnt-1][1];
}
PreUpAvg = UpAvg[1];
preDownAvg = DownAvg[1];
idx = idx + 1;
}
C1[0] = C;
If idx == RSIPeriod+2 Then
{
UpSum = 0;
DownSum = 0;
For Counter = 0 To RSIPeriod - 1 {
UpAmt = C1[Counter] - C1[Counter+1];
If UpAmt >= 0 Then
DownAmt = 0;
Else{
DownAmt = -UpAmt;
UpAmt = 0;
}
UpSum = UpSum + UpAmt;
DownSum = DownSum + DownAmt;
}
UpAvg = UpSum / RSIPeriod;
DownAvg = DownSum / RSIPeriod;
}
If idx > RSIPeriod+2 Then {
UpAmt = C1[0] - C1[1];
If UpAmt >= 0 Then
DownAmt = 0;
Else {
DownAmt = -UpAmt;
UpAmt = 0;
}
UpAvg = (PreUpAvg * (RSIPeriod - 1) + UpAmt) / RSIPeriod;
DownAvg = (preDownAvg * (RSIPeriod - 1) + DownAmt) / RSIPeriod;
}
If UpAvg + DownAvg <> 0 Then
RSIv[0] = 100 * UpAvg / (UpAvg + DownAvg);
Else
RSIv[0] = 0;
if RSIV[Period-1] >= 0 Then
{
hh = RSIV[0];
LL = RSIV[0];
For cnt = 0 to Period-1
{
if RSIV[cnt] > hh Then
hh = RSIV[cnt];
if RSIV[cnt] < ll Then
ll = RSIV[cnt];
}
StoRsi[0] = (RSIv[0]- LL) / (HH-LL) *100 ;
}
if StoRsi[K-1] >= 0 Then
{
sum1 = 0;
For cnt = 0 to K-1
{
sum1 = sum1 + StoRsi[cnt];
}
stok[0] = sum1/K;
plot1(stok[0],"stoRSIK");
}
if Stok[D-1] >= 0 Then
{
sum2 = 0;
For cnt = 0 to D-1
{
sum2 = sum2 + StoK[cnt];
}
stod[0] = sum2/d;
plot2(stoD[0],"stoRSID");
}
PlotBaseLine1(20, "기준선 20");
PlotBaseLine2(80, "기준선 80");
PlotBaseLine3(50, "기준선 50");
}