커뮤니티

수식 문의 드립니다.

프로필 이미지
깜피
2015-01-10 10:55:52
161
글번호 82124
답변완료

첨부 이미지

안녕하세요. 수식 작성 공부 중인에 막히는 부분이 있어서 문의드립니다. 제일모직, 20150109, 1분봉으로 설정했습니다. 제 생각에는 5% 익절 부분에서 수량을 50%로 설정했으니까 14주만 익절하고 8%에서 6주, 12%에서 8주가 익절되는게 맞는 것 같은데 실제로는 다르게 나오는데 틀린 부분 수정 부탁드리겠습니다. 그리고 위에서 처럼 수량 * 0.3 이런 식으로 설정하면 소수점이 발생할 수도 있는데 (예를 들어 수량이 15주 있으면 15*0.3=4.5) 이럴 경우에 몇 주가 잡히게 되는지가 궁금합니다. 감사합니다. -------------------------------------------------------------- input : 오늘(20150109), 아홉시(90000), 진입가격(0), X(3), TsVal1(3), TsVal2(2), range_H(dayclose(1)*1.01),range_L(dayclose(1)*0.99); var : Hval(0), Lval(0),priceB01(0),priceB02(0),priceB03(0),priceB04(0),priceS01(0),priceS02(0),priceS03(0),priceS04(0), final_volume(0), mid_volume(0),수량1(0), 수량2(0),조건1(0), 조건2(0), e_no(0), H1(0),L1(0),H2(0),L2(0),H3(0),L3(0); 수량1= 2000000/dayclose(1); 수량2= 2000000/dayclose(1)*0.5; If MarketPosition == 1 and H>H1 Then { H1=H; } If MarketPosition == 1 and L<L1 Then { L1=L; } if stime >=150000 then { H1=0; L1=0; final_volume=0; mid_volume=0; } /*-----시장가 진입------*/ if DayOpen(0)<=DayClose(1)*1.04 and DayOpen(0)>=DayClose(1)*0.97 and sdate == 오늘 and CurrentEntries==0 and 조건2==0 then { buy("1",AtLimit,c*1.02,수량1); final_volume = final_volume + 수량1; 조건1=1; H1=H; L1=L; } if MarketPosition == 1 and L <= AvgEntryPrice*0.975 and CurrentEntries==1 and 조건2==0 then { buy("2",AtLimit,c*1.02,수량1); final_volume = final_volume + 수량1; 조건1=1; H1=H; L1=L; } If MarketPosition == 1 and L <= AvgEntryPrice * 0.97 Then { ExitLong("3%손절"); 조건1=2; 조건2=1; H1=H; L1=L; } If MarketPosition == 1 and H >= AvgEntryPrice * 1.05 Then { mid_volume = final_volume *0.5; ExitLong("5%익절",Atlimit,C * 0.99,"",mid_volume,1); final_volume = final_volume -mid_volume; 조건1=2; 조건2=1; H1=H; L1=L; } If MarketPosition == 1 and H >= AvgEntryPrice * 1.08 Then { mid_volume = final_volume *0.4; ExitLong("8%익절",AtStop,c*0.99,"",mid_volume,1); final_volume = final_volume -mid_volume; 조건1=2; 조건2=1; H1=H; L1=L; } If MarketPosition == 1 and H >= AvgEntryPrice * 1.12 Then { ExitLong("12%익절"); 조건1=2; 조건2=1; H1=H; L1=L; } SetStopTrailing(4,6,PercentStop,1); /* If MarketPosition == 1 and H >= AvgEntryPrice * 1.05 and L1<H1*0.97 Then { ExitLong("5% trailingstop 익절"); 조건2=1; H1=H; L1=L; } */
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2015-01-12 10:52:38

안녕하세요 예스스탁입니다. 수량은 숫자의 정수자리까지만 인지해 집행됩니다. 현재 작성된 수식에서는 진입/청산 수량계산에 소숫점 자리가 있습니다. 시스템에서 수량을 계산할실때는 정수자리만 취하게 만드셔야 하며 진입수량의 경우 지정한 금액을 초과해서 수량이 잡히면 안되므로 반올림을 해서 구하시면 안됩니다. 소숫점 자리를 버리고 계산하셔야 합니다. 또한 적용하시는 종목이 1주단위로 거래되는 종목인지 10주 단위로 거래되는 종목인지 거래단위를 감안하셔서 작성하셔야 합니다 아래식 참고하시기 바랍니다. 5% 14주 --> 8% 5주(14*0.4 = 5.6) --> 12% 나머지 input : 오늘(20150109), 아홉시(90000), 진입가격(0), X(3), TsVal1(3), TsVal2(2), range_H(dayclose(1)*1.01),range_L(dayclose(1)*0.99); var : Hval(0), Lval(0),priceB01(0),priceB02(0),priceB03(0),priceB04(0),priceS01(0),priceS02(0),priceS03(0),priceS04(0), final_volume(0), mid_volume(0),수량1(0), 수량2(0),조건1(0), 조건2(0), e_no(0), H1(0),L1(0),H2(0),L2(0),H3(0),L3(0); if CodeCategoryEx == 11 and BasePrice < 50000 Then{ 수량1 = int(int(2000000/dayclose(1))/10)*10; 수량2 = int(int(2000000/dayclose(1)*0.5)/10)*10; } Else{ 수량1 = int(2000000/dayclose(1)); 수량2 = int((2000000/dayclose(1))*0.5); } If MarketPosition == 1 and H>H1 Then { H1=H; } If MarketPosition == 1 and L<L1 Then { L1=L; } if stime >=150000 then { H1=0; L1=0; final_volume=0; mid_volume=0; } /*-----시장가 진입------*/ if DayOpen(0)<=DayClose(1)*1.04 and DayOpen(0)>=DayClose(1)*0.97 and sdate == 오늘 and CurrentEntries==0 and 조건2==0 then { buy("1",AtLimit,c*1.02,수량1); 조건1=1; H1=H; L1=L; } if MarketPosition == 1 and L <= AvgEntryPrice*0.975 and CurrentEntries==1 and 조건2==0 then { buy("2",AtLimit,c*1.02,수량1); 조건1=1; H1=H; L1=L; } If MarketPosition == 1 and L <= AvgEntryPrice * 0.97 Then { ExitLong("3%손절"); 조건1=2; 조건2=1; H1=H; L1=L; } If MarketPosition == 1 and H >= AvgEntryPrice * 1.05 Then { if CodeCategoryEx == 11 and BasePrice < 50000 Then mid_volume = int(int(CurrentContracts*0.5)/10)*10; Else mid_volume = int(CurrentContracts*0.5); if CurrentContracts == MaxContracts Then{ ExitLong("5%익절",Atlimit,C * 0.99,"",int(mid_volume),1); 조건1=2; 조건2=1; H1=H; L1=L; } } If MarketPosition == 1 and H >= AvgEntryPrice * 1.08 Then { if CodeCategoryEx == 11 and BasePrice < 50000 Then mid_volume = int(int(CurrentContracts*0.4)/10)*10; Else mid_volume = int(CurrentContracts*0.4); if CurrentContracts < MaxContracts Then{ ExitLong("8%익절",AtStop,c*0.99,"",int(mid_volume),1); 조건1=2; 조건2=1; H1=H; L1=L; } } If MarketPosition == 1 and H >= AvgEntryPrice * 1.12 Then { ExitLong("12%익절"); 조건1=2; 조건2=1; H1=H; L1=L; } SetStopTrailing(4,6,PercentStop,1); /* If MarketPosition == 1 and H >= AvgEntryPrice * 1.05 and L1<H1*0.97 Then { ExitLong("5% trailingstop 익절"); 조건2=1; H1=H; L1=L; } */ 즐거운 하루되세요 > 깜피 님이 쓴 글입니다. > 제목 : 수식 문의 드립니다. > 안녕하세요. 수식 작성 공부 중인에 막히는 부분이 있어서 문의드립니다. 제일모직, 20150109, 1분봉으로 설정했습니다. 제 생각에는 5% 익절 부분에서 수량을 50%로 설정했으니까 14주만 익절하고 8%에서 6주, 12%에서 8주가 익절되는게 맞는 것 같은데 실제로는 다르게 나오는데 틀린 부분 수정 부탁드리겠습니다. 그리고 위에서 처럼 수량 * 0.3 이런 식으로 설정하면 소수점이 발생할 수도 있는데 (예를 들어 수량이 15주 있으면 15*0.3=4.5) 이럴 경우에 몇 주가 잡히게 되는지가 궁금합니다. 감사합니다. -------------------------------------------------------------- input : 오늘(20150109), 아홉시(90000), 진입가격(0), X(3), TsVal1(3), TsVal2(2), range_H(dayclose(1)*1.01),range_L(dayclose(1)*0.99); var : Hval(0), Lval(0),priceB01(0),priceB02(0),priceB03(0),priceB04(0),priceS01(0),priceS02(0),priceS03(0),priceS04(0), final_volume(0), mid_volume(0),수량1(0), 수량2(0),조건1(0), 조건2(0), e_no(0), H1(0),L1(0),H2(0),L2(0),H3(0),L3(0); 수량1= 2000000/dayclose(1); 수량2= 2000000/dayclose(1)*0.5; If MarketPosition == 1 and H>H1 Then { H1=H; } If MarketPosition == 1 and L<L1 Then { L1=L; } if stime >=150000 then { H1=0; L1=0; final_volume=0; mid_volume=0; } /*-----시장가 진입------*/ if DayOpen(0)<=DayClose(1)*1.04 and DayOpen(0)>=DayClose(1)*0.97 and sdate == 오늘 and CurrentEntries==0 and 조건2==0 then { buy("1",AtLimit,c*1.02,수량1); final_volume = final_volume + 수량1; 조건1=1; H1=H; L1=L; } if MarketPosition == 1 and L <= AvgEntryPrice*0.975 and CurrentEntries==1 and 조건2==0 then { buy("2",AtLimit,c*1.02,수량1); final_volume = final_volume + 수량1; 조건1=1; H1=H; L1=L; } If MarketPosition == 1 and L <= AvgEntryPrice * 0.97 Then { ExitLong("3%손절"); 조건1=2; 조건2=1; H1=H; L1=L; } If MarketPosition == 1 and H >= AvgEntryPrice * 1.05 Then { mid_volume = final_volume *0.5; ExitLong("5%익절",Atlimit,C * 0.99,"",mid_volume,1); final_volume = final_volume -mid_volume; 조건1=2; 조건2=1; H1=H; L1=L; } If MarketPosition == 1 and H >= AvgEntryPrice * 1.08 Then { mid_volume = final_volume *0.4; ExitLong("8%익절",AtStop,c*0.99,"",mid_volume,1); final_volume = final_volume -mid_volume; 조건1=2; 조건2=1; H1=H; L1=L; } If MarketPosition == 1 and H >= AvgEntryPrice * 1.12 Then { ExitLong("12%익절"); 조건1=2; 조건2=1; H1=H; L1=L; } SetStopTrailing(4,6,PercentStop,1); /* If MarketPosition == 1 and H >= AvgEntryPrice * 1.05 and L1<H1*0.97 Then { ExitLong("5% trailingstop 익절"); 조건2=1; H1=H; L1=L; } */