커뮤니티

문의 드립니다.

프로필 이미지
느와르
2020-03-30 14:59:13
453
글번호 137310
답변완료
안녕하세요 주말에 이것 저것 시도해 보고 해결이 안되어 문의 드립니다 아직 시스템식에 미진하여 질문이 두서가 없습니다ㅜㅜ 구현하고 싶은것은 진입가격이후 아래와 같이 분할매도를 하고자 합니다. Input : 투입금액(10000000); Var : 진입수량(0); 진입수량 = int(투입금액/C); buy("눌림",OnClose,def,진입수량); 위의 식으로 진입하고 매도는 수량에 의한 분할 매도를 하고자 합니다. (시스템식은 질문의도 예시로 참고해 주세요) 진입가격에서 50비중 3%일부 1차 익절하고 If CurrentContracts == MaxContracts && C >= EntryPrice*1.03 Then ExitLong("3%익절",OnClose,def,"",int(MaxContracts*(50/100)),2); 가정1) 진입가격에서 상한가 직행하면 50비중 청산종료 가정2) 진입가격에서 20%이상까지 상승하고 다시 하락하여 20% CrossDown 50비중을 청산한다. 즉 진입후 올라가면 5%, 10%, 15%, 20%,등등 익절 하는것이 아닌 3%익절 후 최고가까지 상승한후 20%, 15%,10%, 5%,중에서 CrossDown 하고자 합니다. 추가로 시스템식안에 3가지 매수진입식이 있다면 최초 진입식 이후에는 진입하지 않는다, 그리고 a라는 진입식의 손절은 a라는 손절식을 적용한다. b,c의 진입식의 손절은 별도로 지정한다. 그럼 좋은 하루 되세요^^
시스템
답변 2
프로필 이미지

예스스탁 예스스탁 답변

2020-03-30 16:45:41

안녕하세요 예스스탁입니다. 1 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 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 MarketPosition == 1 Then { ExitLong("상한가",atlimit,상한가); if CurrentContracts == MaxContracts and C >= EntryPrice*1.03 Then ExitLong("3%익절",OnClose,def,"",int(MaxContracts*(50/100)),2); if CurrentContracts < MaxContracts then { if highest(c,BarsSinceEntry) >= EntryPrice*1.10 and highest(c,BarsSinceEntry) < EntryPrice*1.20 and C < EntryPrice*1.10 Then ExitLong("btr1"); if highest(c,BarsSinceEntry) >= EntryPrice*1.20 and C < EntryPrice*1.20 Then ExitLong("btr2"); } } 2 "최초 진입식 이후에는 진입하지 않는다," 위 내용은 동일포지션에 대해 추가진입을 하지 않거나 매수진입후에 매도진입으로 스위칭을 하지 않는 다는 내용입니다. 피라미딩은 시스템 트레이딩 설정창에서 피라미딩을 사용하지 않으면 추가진입을 하지 않습니다. 별도로 수식에서 처리할 부분이 없습니다. 스위칭이 되지 않게 하려면 진입식에 MarketPosition == 0 조건을 추가하시면 됩니다. 3 진입별로 청산은 진입이름별로 각각 지정하시면 됩니다. 강제청산이 아니더라도 진입명을 기준으로 청산식 작성하시면 됩니다. if MarketPosition != 0 then { if IsEntryName("a") == true then#진입명이 a일때 SetStopLoss(~~); else if IsEntryName("a") == true then #진입명이 b일때 SetStopLoss(~~); else if IsEntryName("a") == true then #진입명이 c일때 SetStopLoss(~~); Else SetStopLoss(0);#해제 } 즐거운 하루되세요 > 느와르 님이 쓴 글입니다. > 제목 : 문의 드립니다. > 안녕하세요 주말에 이것 저것 시도해 보고 해결이 안되어 문의 드립니다 아직 시스템식에 미진하여 질문이 두서가 없습니다ㅜㅜ 구현하고 싶은것은 진입가격이후 아래와 같이 분할매도를 하고자 합니다. Input : 투입금액(10000000); Var : 진입수량(0); 진입수량 = int(투입금액/C); buy("눌림",OnClose,def,진입수량); 위의 식으로 진입하고 매도는 수량에 의한 분할 매도를 하고자 합니다. (시스템식은 질문의도 예시로 참고해 주세요) 진입가격에서 50비중 3%일부 1차 익절하고 If CurrentContracts == MaxContracts && C >= EntryPrice*1.03 Then ExitLong("3%익절",OnClose,def,"",int(MaxContracts*(50/100)),2); 가정1) 진입가격에서 상한가 직행하면 50비중 청산종료 가정2) 진입가격에서 20%이상까지 상승하고 다시 하락하여 20% CrossDown 50비중을 청산한다. 즉 진입후 올라가면 5%, 10%, 15%, 20%,등등 익절 하는것이 아닌 3%익절 후 최고가까지 상승한후 20%, 15%,10%, 5%,중에서 CrossDown 하고자 합니다. 추가로 시스템식안에 3가지 매수진입식이 있다면 최초 진입식 이후에는 진입하지 않는다, 그리고 a라는 진입식의 손절은 a라는 손절식을 적용한다. b,c의 진입식의 손절은 별도로 지정한다. 그럼 좋은 하루 되세요^^
프로필 이미지

예스스탁 예스스탁 답변

2020-03-31 10:38:35

안녕하세요 예스스탁입니다. var : 당일진입횟수(0); if bdate != bdate[1] Then 당일진입횟수 = 0; if MarketPosition != 0 and MarketPosition != MarketPosition[1] Then 당일진입횟수 = 당일진입횟수+1; 위 수식이 당일진입횟수를 카운트 하는 내용입니다. 진입식에 아래와 같이 조건 추가하시기 바랍니다. if MarketPosition == 0 and 당일진입횟수 < 1 and 매수진입 Then buy(); 즐거운 하루되세요 > 예스스탁 님이 쓴 글입니다. > 제목 : Re : 문의 드립니다. > 안녕하세요 예스스탁입니다. 1 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 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 MarketPosition == 1 Then { ExitLong("상한가",atlimit,상한가); if CurrentContracts == MaxContracts and C >= EntryPrice*1.03 Then ExitLong("3%익절",OnClose,def,"",int(MaxContracts*(50/100)),2); if CurrentContracts < MaxContracts then { if highest(c,BarsSinceEntry) >= EntryPrice*1.10 and highest(c,BarsSinceEntry) < EntryPrice*1.20 and C < EntryPrice*1.10 Then ExitLong("btr1"); if highest(c,BarsSinceEntry) >= EntryPrice*1.20 and C < EntryPrice*1.20 Then ExitLong("btr2"); } } 2 "최초 진입식 이후에는 진입하지 않는다," 위 내용은 동일포지션에 대해 추가진입을 하지 않거나 매수진입후에 매도진입으로 스위칭을 하지 않는 다는 내용입니다. 피라미딩은 시스템 트레이딩 설정창에서 피라미딩을 사용하지 않으면 추가진입을 하지 않습니다. 별도로 수식에서 처리할 부분이 없습니다. 스위칭이 되지 않게 하려면 진입식에 MarketPosition == 0 조건을 추가하시면 됩니다. 3 진입별로 청산은 진입이름별로 각각 지정하시면 됩니다. 강제청산이 아니더라도 진입명을 기준으로 청산식 작성하시면 됩니다. if MarketPosition != 0 then { if IsEntryName("a") == true then#진입명이 a일때 SetStopLoss(~~); else if IsEntryName("a") == true then #진입명이 b일때 SetStopLoss(~~); else if IsEntryName("a") == true then #진입명이 c일때 SetStopLoss(~~); Else SetStopLoss(0);#해제 } 즐거운 하루되세요 > 느와르 님이 쓴 글입니다. > 제목 : 문의 드립니다. > 안녕하세요 주말에 이것 저것 시도해 보고 해결이 안되어 문의 드립니다 아직 시스템식에 미진하여 질문이 두서가 없습니다ㅜㅜ 구현하고 싶은것은 진입가격이후 아래와 같이 분할매도를 하고자 합니다. Input : 투입금액(10000000); Var : 진입수량(0); 진입수량 = int(투입금액/C); buy("눌림",OnClose,def,진입수량); 위의 식으로 진입하고 매도는 수량에 의한 분할 매도를 하고자 합니다. (시스템식은 질문의도 예시로 참고해 주세요) 진입가격에서 50비중 3%일부 1차 익절하고 If CurrentContracts == MaxContracts && C >= EntryPrice*1.03 Then ExitLong("3%익절",OnClose,def,"",int(MaxContracts*(50/100)),2); 가정1) 진입가격에서 상한가 직행하면 50비중 청산종료 가정2) 진입가격에서 20%이상까지 상승하고 다시 하락하여 20% CrossDown 50비중을 청산한다. 즉 진입후 올라가면 5%, 10%, 15%, 20%,등등 익절 하는것이 아닌 3%익절 후 최고가까지 상승한후 20%, 15%,10%, 5%,중에서 CrossDown 하고자 합니다. 추가로 시스템식안에 3가지 매수진입식이 있다면 최초 진입식 이후에는 진입하지 않는다, 그리고 a라는 진입식의 손절은 a라는 손절식을 적용한다. b,c의 진입식의 손절은 별도로 지정한다. 그럼 좋은 하루 되세요^^