커뮤니티

연속 상하한가 종목검색식

프로필 이미지
행복충전
2019-01-30 20:15:17
197
글번호 125778
답변완료
연속 상한가, 연속 하한가를 구하는 종목검색식입니다. 45봉 이상은 검색이 안됩니다. 아래 변수 : 기간(45) 그리고 검색속도도 느립니다. 검증과 수정 부탁합니다. 게시판에는 상한가 함수만 있고 상하한가 일체형 함수는 못 찾았습니다. 상하한가 사용자함수도 부탁드립니다. ############################################################# // (일봉) 특정 기간동안 연속 상한가(연상)가 발생한 종목검색식 ############################################################# // =============== 변수 설명 =============== // 상1하_1(1) : 1이면 상한가, -1이면 하한가 // N일전(0) : N일전 캔들 // 기간(20) : 캔들봉 갯수 // 연상(1) : 연속 상한가 (1연상, 2연상, 3연상, 4연상...) // 일치0이상1(1) : 2연상을 검색한다고 가정할 때 0이면 2연상인 종목(2연상, 3연상, 4연상... 검색 제외)만 검색하고, // 1이면 2연상 이상(2연상, 3연상, 4연상...) 종목 검색 // ii(0), cnt(0) : For문에서 사용 // SangHa : 상하한가 사용자 함수 // ======================================== Input : 상1하_1(1), N일전(0), 기간(20), 연상(1), 일치0이상1(1); // 설명 : 상한가, 0일전, 20일봉, 1연상 이상 종목검색 var : ii(0), cnt(0); cnt = 0; For ii=N일전 To N일전+(기간-1) { If C[ii] == SangHa(상1하_1,ii) Then { //현제봉 상한가이면 cnt = cnt + 1; If C[ii+1] != SangHa(상1하_1,ii+1) Then { //직전봉 상한가 아니면 If 일치0이상1 == 0 Then { //예: 정확한 2연상 종목검색 If cnt == 연상 then Find(cnt); }Else{ //예: 2연상 이상인 종목검색 If cnt >= 연상 then Find(cnt); } cnt = 0; }Else{ //직전봉 상한가이면 If ii == N일전+(기간-1) Then { //마지막 봉이면 If 일치0이상1 == 0 Then { //예: 정확한 2연상 종목검색 If cnt+1 == 연상 then Find(cnt+1); }Else{ //예: 2연상 이상인 종목검색 If cnt+1 >= 연상 then Find(cnt+1); } } } } }
종목검색
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2019-01-31 10:06:56

안녕하세요 예스스탁입니다. 아래 내용 참고하셔서 수정보완해 사용하시기 바랍니다. 1 작성하신 수식은 for루프이므로 봉당 지정한 횟수만큼 반복하게 됩니다. 아래 사용자함수 작성하시고 해당 함수 이용해 작성하시면 됩니다. 상한가 연속2일 input : 상하한(1),연속(2); Condition1 = countif(C >= 상하한가(1),연속) == 연속; if Condition1 == true Then find(1); 최근 N일간 상한가 연속2일 이상이 1회이상 있는 종목 input : 상하한(1),연속(2),N(20); Condition1 = countif(C >= 상하한가(1),연속) == 연속; if countif(Condition1 == true,N) >= 1 Then find(1); 2 사용자함수 매개변수로 상하한가(1)이면 상한가를, -1이면 하한가를 리턴합니다. 함수명 : 상하한가 반환값형 : 숫자형 input : UpDown(Numeric); var : 하한가(0), DnLimit(0); var : dn1(0), dn2(0), dn3(0), dn4(0), dn5(0),dn6(0),dn7(0); var : 상한가(0), UpLimit(0); var : up1(0), up2(0), up3(0), up4(0), up5(0),up6(0),Up7(0); if date >= 19981207 then { if date < 20050328 && CodeCategory() == 2 then DnLimit = (BP * 0.12); Else if date >= 20050328 and date < 20150615 Then DnLimit = (BP * 0.15); Else DnLimit = (BP * 0.30); if CodeCategory() == 2 then { if date >= 20030721 then { dn1 = int(DnLimit/100)*100; dn2 = int(DnLimit/100)*100; dn3 = int(DnLimit/100)*100; dn4 = int(DnLimit/50)*50; dn5 = int(DnLimit/10)*10; dn6 = int(DnLimit/5)*5; dn7 = int(DnLimit/1)*1; } else { dn1 = int(DnLimit/1000)*1000; dn2 = int(DnLimit/500)*500; dn3 = int(DnLimit/100)*100; dn4 = int(DnLimit/50)*50; dn5 = int(DnLimit/10)*10; dn6 = int(DnLimit/10)*10; dn7 = int(DnLimit/1)*1; } } Else { dn1 = int(DnLimit/1000)*1000; dn2 = int(DnLimit/500)*500; dn3 = int(DnLimit/100)*100; dn4 = int(DnLimit/50)*50; dn5 = int(DnLimit/10)*10; dn6 = int(DnLimit/5)*5; dn7 = int(DnLimit/1)*1; } if CodeCategory() == 1 or CodeCategory() == 2 then { if sdate < 20101004 Then{ If BP >= 500000 Then 하한가 = BP-dn1; Else If BP >= 100000 Then 하한가 = BP-dn2; Else If BP >= 50000 Then 하한가 = BP-dn3; Else If BP >= 10000 Then 하한가 = BP-dn4; Else If BP >= 5000 Then 하한가 = BP-dn5; Else If BP >= 1000 Then 하한가 = BP-dn6; Else 하한가 = BP-dn6; } else{ If BP >= 500000 Then 하한가 = BP-dn1; Else If BP >= 100000 Then 하한가 = BP-dn2; Else If BP >= 50000 Then 하한가 = BP-dn3; Else If BP >= 10000 Then 하한가 = BP-dn4; Else If BP >= 5000 Then 하한가 = BP-dn5; Else If BP >= 1000 Then 하한가 = BP-dn6; Else 하한가 = BP-dn7; } } else if CodeCategory() == 8 or CodeCategory() == 9 then { 하한가 = BP-dn6; } } if date >= 19981207 then { if date < 20050328 && CodeCategory() == 2 then UpLimit = (BP[0] * 1.12); Else if date >= 20050328 and date < 20150615 Then UpLimit = (BP[0] * 1.15); Else UpLimit = (BP[0] * 1.30); if CodeCategory() == 2 then { if date >= 20030721 then { up1 = int(UpLimit/100+0.00001)*100; up2 = int(UpLimit/100+0.00001)*100; up3 = int(UpLimit/100+0.00001)*100; up4 = int(UpLimit/50+0.00001)*50; up5 = int(UpLimit/10+0.00001)*10; up6 = int(UpLimit/5+0.00001)*5; up7 = int(UpLimit/1+0.00001)*1; } else { up1 = int(UpLimit/1000+0.00001)*1000; up2 = int(UpLimit/500+0.00001)*500; up3 = int(UpLimit/100+0.00001)*100; up4 = int(UpLimit/50+0.00001)*50; up5 = int(UpLimit/10+0.00001)*10; up6 = int(UpLimit/10+0.00001)*10; up7 = int(UpLimit/1+0.00001)*1; } } Else { up1 = int(UpLimit/1000+0.00001)*1000; up2 = int(UpLimit/500+0.00001)*500; up3 = int(UpLimit/100+0.00001)*100; up4 = int(UpLimit/50+0.00001)*50; up5 = int(UpLimit/10+0.00001)*10; up6 = int(UpLimit/5+0.00001)*5; up7 = int(UpLimit/1+0.00001)*1; } if CodeCategory() == 1 || CodeCategory() == 2 then { if sdate < 20101004 Then{ If BP >= 500000 Then 상한가 = up1; Else If BP >= 100000 Then 상한가 = iff(up2>=500000, up1, up2); Else If BP >= 50000 Then 상한가 = iff(up3>=100000, up2, up3); Else If BP >= 10000 Then 상한가 = iff(up4>=50000, up3, up4); Else If BP >= 5000 Then 상한가 = iff(up5>=10000, up4, up5); Else If BP >= 1000 Then 상한가 = iff(up5>=5000, up5, up6); Else 상한가 = iff(up6>=1000, up6, up6); } Else{ If BP >= 500000 Then 상한가 = up1; Else If BP >= 100000 Then 상한가 = iff(up2>=500000, up1, up2); Else If BP >= 50000 Then 상한가 = iff(up3>=100000, up2, up3); Else If BP >= 10000 Then 상한가 = iff(up4>=50000, up3, up4); Else If BP >= 5000 Then 상한가 = iff(up5>=10000, up4, up5); Else If BP >= 1000 Then 상한가 = iff(up5>=5000, up5, up6); Else 상한가 = iff(up6>=1000, up6, up7); } } else if CodeCategory() == 8 || CodeCategory() == 9 then { // ETF 상한가 = up6; } } if UpDown == 1 Then 상하한가 = 상한가; if UpDown == -1 Then 상하한가 = 하한가; 즐거운 하루되세요 > 행복충전 님이 쓴 글입니다. > 제목 : 연속 상하한가 종목검색식 > 연속 상한가, 연속 하한가를 구하는 종목검색식입니다. 45봉 이상은 검색이 안됩니다. 아래 변수 : 기간(45) 그리고 검색속도도 느립니다. 검증과 수정 부탁합니다. 게시판에는 상한가 함수만 있고 상하한가 일체형 함수는 못 찾았습니다. 상하한가 사용자함수도 부탁드립니다. ############################################################# // (일봉) 특정 기간동안 연속 상한가(연상)가 발생한 종목검색식 ############################################################# // =============== 변수 설명 =============== // 상1하_1(1) : 1이면 상한가, -1이면 하한가 // N일전(0) : N일전 캔들 // 기간(20) : 캔들봉 갯수 // 연상(1) : 연속 상한가 (1연상, 2연상, 3연상, 4연상...) // 일치0이상1(1) : 2연상을 검색한다고 가정할 때 0이면 2연상인 종목(2연상, 3연상, 4연상... 검색 제외)만 검색하고, // 1이면 2연상 이상(2연상, 3연상, 4연상...) 종목 검색 // ii(0), cnt(0) : For문에서 사용 // SangHa : 상하한가 사용자 함수 // ======================================== Input : 상1하_1(1), N일전(0), 기간(20), 연상(1), 일치0이상1(1); // 설명 : 상한가, 0일전, 20일봉, 1연상 이상 종목검색 var : ii(0), cnt(0); cnt = 0; For ii=N일전 To N일전+(기간-1) { If C[ii] == SangHa(상1하_1,ii) Then { //현제봉 상한가이면 cnt = cnt + 1; If C[ii+1] != SangHa(상1하_1,ii+1) Then { //직전봉 상한가 아니면 If 일치0이상1 == 0 Then { //예: 정확한 2연상 종목검색 If cnt == 연상 then Find(cnt); }Else{ //예: 2연상 이상인 종목검색 If cnt >= 연상 then Find(cnt); } cnt = 0; }Else{ //직전봉 상한가이면 If ii == N일전+(기간-1) Then { //마지막 봉이면 If 일치0이상1 == 0 Then { //예: 정확한 2연상 종목검색 If cnt+1 == 연상 then Find(cnt+1); }Else{ //예: 2연상 이상인 종목검색 If cnt+1 >= 연상 then Find(cnt+1); } } } } }