커뮤니티

진입제한

프로필 이미지
짱짱해야지
2019-03-26 10:56:11
389
글번호 127402
답변완료
수고하십니다... 1. 매수전략 전체 진입횟수를 6개로 제한하고, 만약 진입명이 3개("A매수","B매수", "C매수")가 있다면 각 진입의 횟수를 2회로 제한하고, 한개의 진입명에 따라 첫번째 진입 한다면 그후 20봉후에 동일 진입조건이 발생했을 때 추가 1회만 더 진입하려고 합니다. 2. 매도전략 동일 진입(예: "A매수" 2회분)을 수익율이 5%도달시 30% 매도, 10%수익에 30%매도, 그리고 15%일때 전량 매도할 수 있음좋겠습니다. 각 진입명에 따라 수익율은 다르게 할 생각입니다. 항상 감사합니다.
시스템
답변 2
프로필 이미지

예스스탁 예스스탁 답변

2019-03-27 09:50:55

안녕하세요 예스스탁입니다. 1 var : B1(0),B2(0),B3(0); var : I1(0),I2(0),I3(0); if bdate != bdate[1] Then { B1 = 0; B2 = 0; B3 = 0; } if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "A매수" Then { B1 = B1+1; i1 = index; } if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "B매수" Then { B2 = B2+1; i2 = index; } if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "C매수" Then { B3 = B3+1; i3 = index; } if 조건1 and B1 < 2 Then { if MarketPosition == 0 or (MarketPosition == 1 and LatestEntryName(0) == "A매수" and index >= I1+20) Then buy("A매수"); } if 조건2 and B2 < 2 Then { if MarketPosition == 0 or (MarketPosition == 1 and LatestEntryName(0) == "A매수" and index >= I2+20) Then buy("B매수"); } if 조건3 and B3 < 2 Then { if MarketPosition == 0 or (MarketPosition == 1 and LatestEntryName(0) == "A매수" and index >= I3+20) Then buy("C매수"); } 2 var : B1(0),B2(0),B3(0); var : I1(0),I2(0),I3(0); var : V1(0),V2(0),V3(0); var : M1(0),M2(0),M3(0); var : E1(0),E2(0),E3(0); var : X1(0),X2(0),X3(0); if bdate != bdate[1] Then { B1 = 0; B2 = 0; B3 = 0; V1 = 0; V2 = 0; V3 = 0; M1 = 0; M2 = 0; M3 = 0; X1 = 0; X2 = 0; X3 = 0; } if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "A매수" Then { B1 = B1+1; i1 = index; V1 = V1+CurrentContracts-CurrentContracts[1]; #지정이름진입 수량 누적 M1 = M1+(CurrentContracts-CurrentContracts[1])*LatestEntryPrice(0); E1 = M1/V1;#평단가 } if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "B매수" Then { B2 = B2+1; i2 = index; V2 = CurrentContracts-CurrentContracts[1]; M2 = M2+(CurrentContracts-CurrentContracts[1])*LatestEntryPrice(0); E2 = M2/V2; } if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "C매수" Then { B3 = B3+1; i3 = index; V3 = CurrentContracts-CurrentContracts[1]; M3 = M3+(CurrentContracts-CurrentContracts[1])*LatestEntryPrice(0); E3 = M3/V3; } if 조건1 and B1 < 2 Then { if MarketPosition == 0 or (MarketPosition == 1 and LatestEntryName(0) == "A매수" and index >= I1+20) Then buy("A매수"); } if 조건2 and B2 < 2 Then { if MarketPosition == 0 or (MarketPosition == 1 and LatestEntryName(0) == "A매수" and index >= I2+20) Then buy("B매수"); } if 조건3 and B3 < 2 Then { if MarketPosition == 0 or (MarketPosition == 1 and LatestEntryName(0) == "A매수" and index >= I3+20) Then buy("C매수"); } if MarketPosition == 1 then { if B1 >= 1 then { if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Ax1" Then X1 = 1; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Ax2" Then X1 = 2; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Ax3" Then X1 = 3; if X1 == 0 Then ExitLong("Ax1",AtLimit,E1*1.05,"A매수",Floor(V1*0.3),1); if X1 == 1 Then ExitLong("Ax2",AtLimit,E1*1.10,"A매수",Floor(V1*0.3),1); if X1 == 2 Then ExitLong("Ax3",AtLimit,E1*1.15,"A매수"); } if B2 >= 1 then { if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx1" Then X2 = 1; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx2" Then X2 = 2; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx3" Then X2 = 3; if X2 == 0 Then ExitLong("Bx1",AtLimit,E2*1.05,"B매수",Floor(V2*0.3),1); if X2 == 1 Then ExitLong("Bx2",AtLimit,E2*1.10,"B매수",Floor(V2*0.3),1); if X2 == 2 Then ExitLong("Bx3",AtLimit,E2*1.15,"B매수"); } if B3 >= 1 then { if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Cx1" Then X3 = 1; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Cx2" Then X3 = 2; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Cx3" Then X3 = 3; if X3 == 0 Then ExitLong("Cx1",AtLimit,E3*1.05,"A매수",Floor(V3*0.3),1); if X3 == 1 Then ExitLong("Cx2",AtLimit,E3*1.10,"A매수",Floor(V3*0.3),1); if X3 == 2 Then ExitLong("Cx3",AtLimit,E3*1.15,"A매수"); } } 즐거운 하루되세요 > 짱짱해야지 님이 쓴 글입니다. > 제목 : 진입제한 > 수고하십니다... 1. 매수전략 전체 진입횟수를 6개로 제한하고, 만약 진입명이 3개("A매수","B매수", "C매수")가 있다면 각 진입의 횟수를 2회로 제한하고, 한개의 진입명에 따라 첫번째 진입 한다면 그후 20봉후에 동일 진입조건이 발생했을 때 추가 1회만 더 진입하려고 합니다. 2. 매도전략 동일 진입(예: "A매수" 2회분)을 수익율이 5%도달시 30% 매도, 10%수익에 30%매도, 그리고 15%일때 전량 매도할 수 있음좋겠습니다. 각 진입명에 따라 수익율은 다르게 할 생각입니다. 항상 감사합니다.
프로필 이미지

짱짱해야지

2019-04-01 14:41:28

> 제목 : 진입제한 > 수고하십니다... 1. 매수전략 전체 진입횟수를 6개로 제한하고, 만약 진입명이 3개("A매수","B매수", "C매수")가 있다면 각 진입의 횟수를 2회로 제한하고, 한개의 진입명에 따라 첫번째 진입 한다면 그후 20봉후에 동일 진입조건이 발생했을 때 추가 1회만 더 진입하려고 합니다. 2. 매도전략 동일 진입(예: "A매수" 2회분)을 수익율이 5%도달시 30% 매도, 10%수익에 30%매도, 그리고 15%일때 전량 매도할 수 있음좋겠습니다. 각 진입명에 따라 수익율은 다르게 할 생각입니다. 항상 감사합니다. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 일전에 주신 답변 감사합니다. 보내주신 코딩은 Currentcontracts에서 3개의 진입수를 합산하여 처리하는 것 같습니다. 각 진입별로 계약수를 관리하다가 매도 조건에서 매도할수 없는지요? 그리고 Daytrading말고 매수조건 이후 매도조건 발생할때까지 길게 가져가는 것으로 하고 싶습니다. 아래와 같이 작성했는데, 시작 조건일의 첫번째 조건의 진입매수와 매도 3번을 정상적으로 작동하지만, 그 이후 여러개 진입이 동시에 일어날 경우, 매도가 1,2번은 생략되고 3번 매도만 발생하는 등의 문제가 있습니다. 아마도 B1, V1, i1, M1, E1,X1,z1 등을 언제 초기화하는가에 문제가 있는 것 같습니다. 아마도 M과 E에 대한 다른 접근이 필요한 것 같기도 합니다. IF SDate > 20160901 then Begin # 조건변수 처리 if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "DP_B" Then{ B1 = B1+1; i1 = index; V1 = V1+CurrentContracts-CurrentContracts[1]; #지정이름진입 수량 누적 M1 = M1+(CurrentContracts-CurrentContracts[1])*LatestEntryPrice(0); E1 = M1/V1;#평단가 } if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "CC_B" Then{ B2 = B2+1; i2 = index; V2 = V2+CurrentContracts-CurrentContracts[1]; M2 = M2+(CurrentContracts-CurrentContracts[1])*LatestEntryPrice(0); E2 = M2/V2; } if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "GS_B" Then{ B3 = B3+1; i3 = index; V3 = V3+CurrentContracts-CurrentContracts[1]; M3 = M3+(CurrentContracts-CurrentContracts[1])*LatestEntryPrice(0); E3 = M3/V3; } #### 매수조건 if DispBuy==1 and B1 < 2 Then{ if MarketPosition == 0 or LatestEntryName(0) != "DP_B" or (MarketPosition == 1 and LatestEntryName(0) == "DP_B" and index >= I1+20) Then buy("DP_B"); } if M_CCI == 1 and B2 < 2 Then{ if MarketPosition == 0 or LatestEntryName(0) != "CC_B" or (MarketPosition == 1 and LatestEntryName(0) == "CC_B" and index >= I2+20) Then buy("CC_B"); } iF crossDown(ma20, ma60) then CD_Check1 = index;{ if CD_Check1 + 11 < index then { if C <= 선행스팬2[52] and CrossUp(D_MA5, D_Dnline) then{ if MarketPosition == 0 or LatestEntryName(0) != "GS_B" or (MarketPosition == 1 and LatestEntryName(0) == "GS_B" and index >= I2+20) Then buy("GS_B"); } } } ### 매도 전략 if MarketPosition == 1 then{ if B1 >= 1 then{ if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "DP_S1" Then X1 = 1; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "DP_S2" Then X1 = 2; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "DP_S3" Then {X1 = 3; z1 = 1;} if X1 == 0 Then ExitLong("DP_S1",AtLimit,E1*1.05,"DP_B",Floor(V1*0.3),1); if X1 == 1 Then ExitLong("DP_S2",AtLimit,E1*1.10,"DP_B",Floor(V1*0.3),1); if X1 == 2 Then ExitLong("DP_S3",AtLimit,E1*1.15,"DP_B"); } } if MarketPosition == 1 then{ if B2 >= 1 then{ if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "CC_S1" Then X2 = 1; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "CC_S2" Then X2 = 2; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "CC_S3" Then {X2 = 3; z2 = 1;} if X2 == 0 Then ExitLong("CC_S1",AtLimit,E2*1.05,"CC_B",Floor(V2*0.3),1); if X2 == 1 Then ExitLong("CC_S2",AtLimit,E2*1.10,"CC_B",Floor(V2*0.3),1); if X2 == 2 Then ExitLong("CC_S3",AtLimit,E2*1.15,"CC_B"); } } if MarketPosition == 1 then{ if B3 >= 1 then{ if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "GS_S1" Then X3 = 1; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "GS_S2" Then X3 = 2; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "GS_S3" Then {X3 = 3; z3 = 1;} if X3 == 0 Then ExitLong("GS_S1",AtLimit,E3*1.05,"GS_B",Floor(V3*0.3),1); if X3 == 1 Then ExitLong("GS_S2",AtLimit,E3*1.10,"GS_B",Floor(V3*0.3),1); if X3 == 2 Then ExitLong("GS_S3",AtLimit,E3*1.15,"GS_B"); } } if CurrentContracts == 0 or z1[1] == 1 then {B1 = 0; V1 = 0; i1 = 0; M1 = 0; E1 = 0; X1 = 0; z1 = 0;} if CurrentContracts == 0 or z2[1] == 1 then {B2 = 0; V2 = 0; i2 = 0; M2 = 0; E2 = 0; X2 = 0; z2 = 0;} if CurrentContracts == 0 or z3[1] == 1 then {B3 = 0; V3 = 0; i3 = 0; M3 = 0; E3 = 0; X3 = 0; z3 = 0;}