커뮤니티
수식점검요망.
2016-04-21 08:28:41
98
글번호 97304
아래 수식이 무엇이 잘못되었는지 확인 바랍니다..
data1만 나오고 data2는 출력이 되지 않네요.
수정해 주시기 바랍니다.
var : month1(0,data1),nday1(0,data1),week1(0,data1),daycnt1(0,data1),cnt1(0,data1),sum1(0,data1),sum2(0,data1),avg1(0,data1),avg2(0,data1);
month1 = data1(int(date/100)-int(date/10000)*100);
nday1 = data1(date - int(date/100)*100);
week1 = data1(DayOfWeek(date));
if data1(nday1 >= 8 and nday1 <= 14 and week1 == 4) or data1(sdate == 20141008) then
Condition1 = true;
Else
Condition1 = false;
if data1(Condition1 == false and Condition1[1] == true) and Data1(date != date[1]) Then
daycnt1 = 0;
if Data1(date != date[1]) Then
daycnt1 = daycnt1+1;
sum1 = 0;
sum2 = 0;
for cnt1 = 0 to daycnt1-1{
sum1 = sum1+DayClose(cnt1);
sum2 = sum2+(DayHigh(cnt1)+DayLow(cnt1))/2;
}
avg1 = sum1/daycnt1;
avg2 = sum2/daycnt1;
plot1(avg1,"종가기준평균1");
plot2(avg2,"중심값기준평균1");
var : month2(0,data2),nday2(0,data2),week2(0,data2),daycnt2(0,data2),cnt2(0,data2),sum3(0,data2),sum4(0,data2),avg3(0,data2),avg4(0,data2);
month2 = data2(int(date/100)-int(date/10000)*100);
nday2 = data2(date - int(date/100)*100);
week2 = data2(DayOfWeek(date));
if Data2(nday2 >= 8 and nday2 <= 14 and week2 == 4) or Data2(sdate == 20141008) then
Condition2 = true;
Else
Condition2 = false;
if Data2(Condition2 == false and Condition2[1] == true) and data2(date != date[1]) Then
daycnt2 = 0;
if data2(date != date[1]) Then
daycnt2 = daycnt2+1;
sum3 = 0;
sum4 = 0;
for cnt2 = 0 to daycnt2-1{
sum3 = sum3+DayClose(cnt2);
sum4 = sum4+(DayHigh(cnt2)+DayLow(cnt2))/2;
}
avg3 = sum3/daycnt2;
avg4 = sum4/daycnt2;
plot3(avg3,"종가기준평균2");
plot4(avg4,"중심값기준평균2");
답변 1
예스스탁 예스스탁 답변
2016-04-21 14:43:08
안녕하세요
예스스탁입니다.
dayhigh,daylow,dayclose,dayopen은
기본차트 종목(data1)의 일간값을 가져오는 함수입니다.
data2등에 사용하셔도 항상 data1값만 가져오게 됩니다.
참조데이터에서는 highD,lowD,closeD,openD함수를 사용하게 되는데
for문에서 가변적으로 이전일의 값을 불러오므로
따로 수식에서 값을 계산해 사용해야 합니다.
아래 수정한 식입니다. 참고하시기 바랍니다.
var : month1(0,data1),nday1(0,data1),week1(0,data1),daycnt1(0,data1),cnt1(0,data1),sum1(0,data1),sum2(0,data1),avg1(0,data1),avg2(0,data1);
month1 = data1(int(date/100)-int(date/10000)*100);
nday1 = data1(date - int(date/100)*100);
week1 = data1(DayOfWeek(date));
if data1(nday1 >= 8 and nday1 <= 14 and week1 == 4) or data1(sdate == 20141008) then
Condition1 = true;
Else
Condition1 = false;
if data1(Condition1 == false and Condition1[1] == true) and Data1(date != date[1]) Then
daycnt1 = 0;
if Data1(date != date[1]) Then
daycnt1 = daycnt1+1;
sum1 = 0;
sum2 = 0;
for cnt1 = 0 to daycnt1-1{
sum1 = sum1+DayClose(cnt1);
sum2 = sum2+(DayHigh(cnt1)+DayLow(cnt1))/2;
}
avg1 = sum1/daycnt1;
avg2 = sum2/daycnt1;
plot1(avg1,"종가기준평균1");
plot2(avg2,"중심값기준평균1");
var : month2(0,data2),nday2(0,data2),week2(0,data2),daycnt2(0,data2),cnt2(0,data2),sum3(0,data2),sum4(0,data2),avg3(0,data2),avg4(0,data2),cnt(0,data2);
Array : O2[50](0,data2),H2[50](0,data2),L2[50](0,data2),C2[50](0,data2);
if data2(date != date[1]) Then{
O2[0] = O;
H2[0] = H;
L2[0] = L;
for cnt = 1 to 49{
O2[cnt] = O2[cnt-1][1];
H2[cnt] = H2[cnt-1][1];
L2[cnt] = L2[cnt-1][1];
C2[cnt] = C2[cnt-1][1];
}
}
if data2(H) > H2[0] Then
H2[0] = data2(H);
if data2(L) < L2[0] Then
L2[0] = data2(L);
C2[0] = data2(C);
month2 = data2(int(date/100)-int(date/10000)*100);
nday2 = data2(date - int(date/100)*100);
week2 = data2(DayOfWeek(date));
if Data2(nday2 >= 8 and nday2 <= 14 and week2 == 4) or Data2(sdate == 20141008) then
Condition2 = true;
Else
Condition2 = false;
if Data2(Condition2 == false and Condition2[1] == true) and data2(date != date[1]) Then
daycnt2 = 0;
if data2(date != date[1]) Then
daycnt2 = daycnt2+1;
sum3 = 0;
sum4 = 0;
for cnt2 = 0 to daycnt2-1{
sum3 = sum3+C2[cnt2];
sum4 = sum4+(H2[cnt2]+Low[cnt2])/2;
}
avg3 = sum3/daycnt2;
avg4 = sum4/daycnt2;
plot3(avg3,"종가기준평균2");
plot4(avg4,"중심값기준평균2");
즐거운 하루되세요
> khkwon 님이 쓴 글입니다.
> 제목 : 수식점검요망.
> 아래 수식이 무엇이 잘못되었는지 확인 바랍니다..
data1만 나오고 data2는 출력이 되지 않네요.
수정해 주시기 바랍니다.
var : month1(0,data1),nday1(0,data1),week1(0,data1),daycnt1(0,data1),cnt1(0,data1),sum1(0,data1),sum2(0,data1),avg1(0,data1),avg2(0,data1);
month1 = data1(int(date/100)-int(date/10000)*100);
nday1 = data1(date - int(date/100)*100);
week1 = data1(DayOfWeek(date));
if data1(nday1 >= 8 and nday1 <= 14 and week1 == 4) or data1(sdate == 20141008) then
Condition1 = true;
Else
Condition1 = false;
if data1(Condition1 == false and Condition1[1] == true) and Data1(date != date[1]) Then
daycnt1 = 0;
if Data1(date != date[1]) Then
daycnt1 = daycnt1+1;
sum1 = 0;
sum2 = 0;
for cnt1 = 0 to daycnt1-1{
sum1 = sum1+DayClose(cnt1);
sum2 = sum2+(DayHigh(cnt1)+DayLow(cnt1))/2;
}
avg1 = sum1/daycnt1;
avg2 = sum2/daycnt1;
plot1(avg1,"종가기준평균1");
plot2(avg2,"중심값기준평균1");
var : month2(0,data2),nday2(0,data2),week2(0,data2),daycnt2(0,data2),cnt2(0,data2),sum3(0,data2),sum4(0,data2),avg3(0,data2),avg4(0,data2);
month2 = data2(int(date/100)-int(date/10000)*100);
nday2 = data2(date - int(date/100)*100);
week2 = data2(DayOfWeek(date));
if Data2(nday2 >= 8 and nday2 <= 14 and week2 == 4) or Data2(sdate == 20141008) then
Condition2 = true;
Else
Condition2 = false;
if Data2(Condition2 == false and Condition2[1] == true) and data2(date != date[1]) Then
daycnt2 = 0;
if data2(date != date[1]) Then
daycnt2 = daycnt2+1;
sum3 = 0;
sum4 = 0;
for cnt2 = 0 to daycnt2-1{
sum3 = sum3+DayClose(cnt2);
sum4 = sum4+(DayHigh(cnt2)+DayLow(cnt2))/2;
}
avg3 = sum3/daycnt2;
avg4 = sum4/daycnt2;
plot3(avg3,"종가기준평균2");
plot4(avg4,"중심값기준평균2");
다음글
이전글