커뮤니티

55709글 관련 재질문

프로필 이미지
ajs
2017-11-30 21:58:22
146
글번호 114614
답변완료
질문을 통해 받은 기준자산 3분할 매매식을 아래와 같은 기준수량 3분할 매매식으로 고쳐보았습니다. input : 기준수량(100); var : ET1(0),ET2(0),ET3(0); if Bdate != Bdate[1] Then{ if stime < 100000 Then { ET1 = 90000; ET2 = 90300; ET3 = 90600; } else { ET1 = 100000; ET2 = 100300; ET3 = 100600; } } if stime == 142700 or (stime > 142700 and stime[1] < 142700) Then{ var1 = 기준수량*(1/3); buy("b1",OnClose,def,Floor(var1)); } if stime == 143000 or (stime > 143000 and stime[1] < 143000) Then{ var1 = 기준수량*(1/3); buy("b2",OnClose,def,Floor(var1)); } if stime == 143300 or (stime > 143300 and stime[1] < 143300) Then{ var1 = 기준수량*(1/3); buy("b3",OnClose,def,Floor(var1)); } if MarketPosition == 1 and sdate > EntryDate then{ if stime == ET1 or (stime > ET1 and stime[1] < ET1) Then ExitLong("bx1",OnClose,def,"",floor(MaxContracts*(1/3)),1); if stime == ET2 or (stime > ET2 and stime[1] < ET2) Then ExitLong("bx2",OnClose,def,"",floor(MaxContracts*(1/3)),1); if stime == ET3 or (stime > ET3 and stime[1] < ET3) Then ExitLong("bx3"); } 기준수량을 100(3의 배수가 아님)으로 설정하니 33개씩 매매가 되고 1개가 남습니다. 3번째 매매(b3, bx3) 때 잔량 전부(34개)를 매매하게 하려면 식을 어떻게 수정해야 할까요? 감사합니다.
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2017-12-01 11:19:23

안녕하세요 예스스탁입니다. input : 기준수량(100); var : ET1(0),ET2(0),ET3(0); if Bdate != Bdate[1] Then{ if stime < 100000 Then { ET1 = 90000; ET2 = 90300; ET3 = 90600; } else { ET1 = 100000; ET2 = 100300; ET3 = 100600; } } if stime == 142700 or (stime > 142700 and stime[1] < 142700) Then{ var1 = Floor(기준수량*(1/3)); buy("b1",OnClose,def,var1); } if stime == 143000 or (stime > 143000 and stime[1] < 143000) Then{ var2 = Floor(기준수량*(1/3)); buy("b2",OnClose,def,var2); } if stime == 143300 or (stime > 143300 and stime[1] < 143300) Then{ var3 = 기준수량-var1-var2; buy("b3",OnClose,def,var3); } if MarketPosition == 1 and sdate > EntryDate then{ if stime == ET1 or (stime > ET1 and stime[1] < ET1) Then ExitLong("bx1",OnClose,def,"",floor(MaxContracts*(1/3)),1); if stime == ET2 or (stime > ET2 and stime[1] < ET2) Then ExitLong("bx2",OnClose,def,"",floor(MaxContracts*(1/3)),1); if stime == ET3 or (stime > ET3 and stime[1] < ET3) Then ExitLong("bx3"); } 즐거운 하루되세요 > ajs 님이 쓴 글입니다. > 제목 : 55709글 관련 재질문 > 질문을 통해 받은 기준자산 3분할 매매식을 아래와 같은 기준수량 3분할 매매식으로 고쳐보았습니다. input : 기준수량(100); var : ET1(0),ET2(0),ET3(0); if Bdate != Bdate[1] Then{ if stime < 100000 Then { ET1 = 90000; ET2 = 90300; ET3 = 90600; } else { ET1 = 100000; ET2 = 100300; ET3 = 100600; } } if stime == 142700 or (stime > 142700 and stime[1] < 142700) Then{ var1 = 기준수량*(1/3); buy("b1",OnClose,def,Floor(var1)); } if stime == 143000 or (stime > 143000 and stime[1] < 143000) Then{ var1 = 기준수량*(1/3); buy("b2",OnClose,def,Floor(var1)); } if stime == 143300 or (stime > 143300 and stime[1] < 143300) Then{ var1 = 기준수량*(1/3); buy("b3",OnClose,def,Floor(var1)); } if MarketPosition == 1 and sdate > EntryDate then{ if stime == ET1 or (stime > ET1 and stime[1] < ET1) Then ExitLong("bx1",OnClose,def,"",floor(MaxContracts*(1/3)),1); if stime == ET2 or (stime > ET2 and stime[1] < ET2) Then ExitLong("bx2",OnClose,def,"",floor(MaxContracts*(1/3)),1); if stime == ET3 or (stime > ET3 and stime[1] < ET3) Then ExitLong("bx3"); } 기준수량을 100(3의 배수가 아님)으로 설정하니 33개씩 매매가 되고 1개가 남습니다. 3번째 매매(b3, bx3) 때 잔량 전부(34개)를 매매하게 하려면 식을 어떻게 수정해야 할까요? 감사합니다.