커뮤니티

시스템 수식 수정 부탁드립니다.

프로필 이미지
승부사1
2015-07-06 21:34:18
108
글번호 88058
답변완료
아래의 수식에 대해서 몇가지 수정을 부탁드립니다. 매수와 매도는 잘 적용되는 것을 확인했습니다. 1. 기준봉이 음봉인 경우를 배제하고 양봉인 경우로만 설정 부탁드립니다. 2. 손절 규정이 적용이 안된것 같아서요. 손절 규정을 손절 1: 기준봉의 저가 -1%를 이탈시 전량매도 손절 2: 기준봉의 저가 -!%를 이탈시 보유수량의 50% 매도 이렇게 두개를 만들어주시면 제가 더 테스트를 해보고 둘중 하나를 빼도록 하겠습니다. 3. 상한가 규정이 오류가 간혹 있습니다. 6월 15일 이후 챠트에서도 15%에서 매도되는 경우가 있군요. 한번더 점검 부탁드립니다. - 아 래 - input : 기준봉날짜 (20150701); 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 sdate == 기준봉날짜 Then{ value1 = abs(DayClose-dayopen); value2 = max(DayClose,dayopen); if DayClose > DayOpen Then{ var1 = dayopen+value1*0.75; var2 = dayopen+value1*0.50; var3 = dayopen+value1*0.25; } Else{ var1 = dayopen-value1*0.75; var2 = dayopen-value1*0.50; var3 = dayopen-value1*0.25; } } if sdate > 기준봉날짜 Then{ #var1(75%)터치시 매수 if Condition1 == false and H < var1 Then Buy("매수11",AtStop,var1); if Condition1 == false and L > var1 Then Buy("매수12",Atlimit,var1); #var2(50%)터치시 매수 if Condition2 == false and H < var2 Then Buy("매수21",AtStop,var2); if Condition2 == false and L > var2 Then Buy("매수22",Atlimit,var2); #var3(25%)터치시 매수 if Condition3 == false and H < var3 Then Buy("매수31",AtStop,var3); if Condition3 == false and L > var3 Then Buy("매수32",Atlimit,var3); } if MarketPosition == 1 Then{ if LatestEntryName(0) == "매수11" or LatestEntryName(0) == "매수12" Then Condition1 = true; if LatestEntryName(0) == "매수21" or LatestEntryName(0) == "매수22" Then Condition2 = true; if LatestEntryName(0) == "매수31" or LatestEntryName(0) == "매수32" Then Condition3 = true; ExitLong("상한가매도",atlimit,상한가); if daylow(1)*0.99 > value2 Then Exitlong("매도",AtStop,daylow(1)*0.99); } Else{ Condition1 = false; Condition2 = false; Condition3 = false; }
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2015-07-07 09:53:34

안녕하세요 예스스탁입니다. 수정한 식입니다. 상한가 부분은 값이 정확히 나오고 있습니다. 수식에서 atlimit이나 atstop은 현재봉에서 세팅해서 다음봉에서 해당 가격을 터치하는 즉시 신호가 발생합니다. 당일 마지막봉에서 셋팅되서 다음날 신호가 나오면 전날 상한가의 가격으로 청산이 됩니다. 마지막봉에는 셋팅이 되지 않게 수정했습니다. 마지막봉은 시간으로만 지정가능합니다. 15시봉에는 셋팅이 되지 않게 했습니다. 해당식 분봉에 적용하셔야 합니다. input : 기준봉날짜 (20150701); 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 sdate == 기준봉날짜 Then{ value1 = abs(DayClose-dayopen); value2 = max(DayClose,dayopen); value3 = DayOpen; value4 = DayClose; if DayClose > DayOpen Then{ var1 = dayopen+value1*0.75; var2 = dayopen+value1*0.50; var3 = dayopen+value1*0.25; } Else{ var1 = dayopen-value1*0.75; var2 = dayopen-value1*0.50; var3 = dayopen-value1*0.25; } } if sdate > 기준봉날짜 and value4 > value3 Then{ #var1(75%)터치시 매수 if Condition1 == false and H < var1 Then Buy("매수11",AtStop,var1); if Condition1 == false and L > var1 Then Buy("매수12",Atlimit,var1); #var2(50%)터치시 매수 if Condition2 == false and H < var2 Then Buy("매수21",AtStop,var2); if Condition2 == false and L > var2 Then Buy("매수22",Atlimit,var2); #var3(25%)터치시 매수 if Condition3 == false and H < var3 Then Buy("매수31",AtStop,var3); if Condition3 == false and L > var3 Then Buy("매수32",Atlimit,var3); } if MarketPosition == 1 Then{ if LatestEntryName(0) == "매수11" or LatestEntryName(0) == "매수12" Then Condition1 = true; if LatestEntryName(0) == "매수21" or LatestEntryName(0) == "매수22" Then Condition2 = true; if LatestEntryName(0) == "매수31" or LatestEntryName(0) == "매수32" Then Condition3 = true; if stime < 150000 then ExitLong("상한가매도",atlimit,상한가); Exitlong("손절1",AtStop,daylow(1)*0.99); Exitlong("손절2",AtStop,daylow(1)*0.99,"",Floor(CurrentContracts*0.5),1); } Else{ Condition1 = false; Condition2 = false; Condition3 = false; } 즐거운 하루되세요 > 승부사1 님이 쓴 글입니다. > 제목 : 시스템 수식 수정 부탁드립니다. > 아래의 수식에 대해서 몇가지 수정을 부탁드립니다. 매수와 매도는 잘 적용되는 것을 확인했습니다. 1. 기준봉이 음봉인 경우를 배제하고 양봉인 경우로만 설정 부탁드립니다. 2. 손절 규정이 적용이 안된것 같아서요. 손절 규정을 손절 1: 기준봉의 저가 -1%를 이탈시 전량매도 손절 2: 기준봉의 저가 -!%를 이탈시 보유수량의 50% 매도 이렇게 두개를 만들어주시면 제가 더 테스트를 해보고 둘중 하나를 빼도록 하겠습니다. 3. 상한가 규정이 오류가 간혹 있습니다. 6월 15일 이후 챠트에서도 15%에서 매도되는 경우가 있군요. 한번더 점검 부탁드립니다. - 아 래 - input : 기준봉날짜 (20150701); 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 sdate == 기준봉날짜 Then{ value1 = abs(DayClose-dayopen); value2 = max(DayClose,dayopen); if DayClose > DayOpen Then{ var1 = dayopen+value1*0.75; var2 = dayopen+value1*0.50; var3 = dayopen+value1*0.25; } Else{ var1 = dayopen-value1*0.75; var2 = dayopen-value1*0.50; var3 = dayopen-value1*0.25; } } if sdate > 기준봉날짜 Then{ #var1(75%)터치시 매수 if Condition1 == false and H < var1 Then Buy("매수11",AtStop,var1); if Condition1 == false and L > var1 Then Buy("매수12",Atlimit,var1); #var2(50%)터치시 매수 if Condition2 == false and H < var2 Then Buy("매수21",AtStop,var2); if Condition2 == false and L > var2 Then Buy("매수22",Atlimit,var2); #var3(25%)터치시 매수 if Condition3 == false and H < var3 Then Buy("매수31",AtStop,var3); if Condition3 == false and L > var3 Then Buy("매수32",Atlimit,var3); } if MarketPosition == 1 Then{ if LatestEntryName(0) == "매수11" or LatestEntryName(0) == "매수12" Then Condition1 = true; if LatestEntryName(0) == "매수21" or LatestEntryName(0) == "매수22" Then Condition2 = true; if LatestEntryName(0) == "매수31" or LatestEntryName(0) == "매수32" Then Condition3 = true; ExitLong("상한가매도",atlimit,상한가); if daylow(1)*0.99 > value2 Then Exitlong("매도",AtStop,daylow(1)*0.99); } Else{ Condition1 = false; Condition2 = false; Condition3 = false; }