커뮤니티

수식 확인 부탁드립니다.

프로필 이미지
대한이
2022-07-13 09:41:44
1465
글번호 160693
답변완료
안녕하십니까 작성하여 주신 수식 검토 부탁드립니다. ------------------------------------------------------------------------- input : P(20),이평기간(5); var : cnt(0),sum1(0),mav1(0),sum2(0),mav2(0),t(0),count(0); var : 상한가(0), UpLimit(0); var : up1(0), up2(0), up3(0), up4(0), up5(0),up6(0),Up7(0); Array : 상[100](False); 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 Bdate != Bdate[1] Then { For cnt = 99 DownTo 1 { 상[cnt] = 상[cnt-1]; } } if C == 상한가 Then 상[0] = true; Else 상[0] = False; count = 0; For cnt = 0 to P-1 { if 상[cnt] == true Then count = count+1; } sum1 = 0; sum2 = NextBarOpen; For cnt = 0 to 이평기간-1 { sum1 = sum1 + DayClose(cnt); if cnt < P-1 Then sum2 = sum2 + DayClose(cnt); } mav1 = sum1/이평기간; mav2 = sum2/이평기간; if NextBarSdate != sDate Then { T = 0; if C <= mav1*1.15 and C >= mav1*0.85 and count >= 1 Then { T = 1; if NextBarOpen < mav2 Then { T = 2; Buy("b11",AtMarket); } Else { T = 3; Buy("b12",AtLimit,mav2); } } Condition1 = False; } Else { if L <= mav1 Then Condition1 = true; if Condition1 == False and T == 3 Then Buy("b2",AtLimit,mav2); } SetStopEndofday(151800); SetStopLoss(5,PercentStop); #ㅇ 매수 # 1. 최근 20거래일 중 종가 상한가 # 2. 일봉 상 가격 형성이 5일선 기준 +-15% 이내 # 3. 당일 시가가 일봉기준 5일선 위에서 시작하면 당일 일봉 상 5일 이동평균선에 닿거나 하향하면 바로 매수 # 4. 당일 시가가 일봉기준 5일선 아래에서 시작하면 시가로 매수 주문 #매수 주문은 시가가 전일종가 대비 +-20 이내에서 형성될때만 나갈수있게 부탁드립니다. #ㅇ 매도 #오후 3시 18분 전량매도 검토 요청 5일선 위에서 시가가 형성되어도 시가로 매수 주문이 발생 합니다. 확인 부탁드립니다., 감사합니다.
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2022-07-13 17:30:17

안녕하세요 예스스탁입니다. 답변드린 수식은 이전에 사용하시는 식에서 일봉이평만 별도로 기간을 지정할 수 있게 수정이 된 식입니다. sum1 = 0; sum2 = NextBarOpen; count = 0; For cnt = 0 to P-1 { sum1 = sum1 + DayClose(cnt); if cnt < P-1 Then sum2 = sum2 + DayClose(cnt); if 상[cnt] == true Then count = count+1; } mav1 = sum1/P; mav2 = sum2/P; 위 내용을 아래와 같이 단지 분리한 것 뿐입니다. count = 0; For cnt = 0 to P-1 { if 상[cnt] == true Then count = count+1; } sum1 = 0; sum2 = NextBarOpen; For cnt = 0 to 이평기간-1 { sum1 = sum1 + DayClose(cnt); if cnt < P-1 Then sum2 = sum2 + DayClose(cnt); } mav1 = sum1/이평기간; mav2 = sum2/이평기간; 기존에 사용하는 다른 수식코드에 변경된 부분이 없고 다른 부분에 영향이 없습니다. 기존에도 시초가가 시초가 기준 이평보다 작으면 시초가에 매수 시초가가 시초가 기준 이평보다 크면 시초가 기준 이평값까지 하락하면 매수입니다. 수식에 별도로 수정해 드릴 부분이 없습니다. 변경전 수식코드와 비교해 보시기 바랍니다. 즐거운 하루되세요 > 대한이 님이 쓴 글입니다. > 제목 : 수식 확인 부탁드립니다. > 안녕하십니까 작성하여 주신 수식 검토 부탁드립니다. ------------------------------------------------------------------------- input : P(20),이평기간(5); var : cnt(0),sum1(0),mav1(0),sum2(0),mav2(0),t(0),count(0); var : 상한가(0), UpLimit(0); var : up1(0), up2(0), up3(0), up4(0), up5(0),up6(0),Up7(0); Array : 상[100](False); 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 Bdate != Bdate[1] Then { For cnt = 99 DownTo 1 { 상[cnt] = 상[cnt-1]; } } if C == 상한가 Then 상[0] = true; Else 상[0] = False; count = 0; For cnt = 0 to P-1 { if 상[cnt] == true Then count = count+1; } sum1 = 0; sum2 = NextBarOpen; For cnt = 0 to 이평기간-1 { sum1 = sum1 + DayClose(cnt); if cnt < P-1 Then sum2 = sum2 + DayClose(cnt); } mav1 = sum1/이평기간; mav2 = sum2/이평기간; if NextBarSdate != sDate Then { T = 0; if C <= mav1*1.15 and C >= mav1*0.85 and count >= 1 Then { T = 1; if NextBarOpen < mav2 Then { T = 2; Buy("b11",AtMarket); } Else { T = 3; Buy("b12",AtLimit,mav2); } } Condition1 = False; } Else { if L <= mav1 Then Condition1 = true; if Condition1 == False and T == 3 Then Buy("b2",AtLimit,mav2); } SetStopEndofday(151800); SetStopLoss(5,PercentStop); #ㅇ 매수 # 1. 최근 20거래일 중 종가 상한가 # 2. 일봉 상 가격 형성이 5일선 기준 +-15% 이내 # 3. 당일 시가가 일봉기준 5일선 위에서 시작하면 당일 일봉 상 5일 이동평균선에 닿거나 하향하면 바로 매수 # 4. 당일 시가가 일봉기준 5일선 아래에서 시작하면 시가로 매수 주문 #매수 주문은 시가가 전일종가 대비 +-20 이내에서 형성될때만 나갈수있게 부탁드립니다. #ㅇ 매도 #오후 3시 18분 전량매도 검토 요청 5일선 위에서 시가가 형성되어도 시가로 매수 주문이 발생 합니다. 확인 부탁드립니다., 감사합니다.