커뮤니티

문의드립니다

프로필 이미지
쿠루드
2016-07-27 08:46:33
110
글번호 100426
답변완료
안녕하세요 문의를 통해 아래와 같이 수식을 변경했는데 진입은 원하는대로 구현이 됩니다 한가지만 수정 보완 부탁드립니다 목표틱인 p1, p2에 도달했을때만 새로운 진입이 돼야 하는데.. 로스컷인 L1, L2에 도달했을때도 추가 스위칭 하지 않고 새로운 진입을 합니다 이부분만 보완 부탁합니다 감사합니다 -------------------------------------------------------------------------------------- input : period1(5),period2(20),ST1(80000),ST2(153000),L1(20),P1(15),L2(25),P2(20),N(5); Var : cross(0),vol(0),T(0),EE(0),cnt(0); Array : cond[5](false); var1 = ma(c,period1); var2 = ma(c,period2); if MarketPosition != 0 Then{ if PositionProfit < 0 Then Vol = MaxContracts*2; Else vol = 1; } if MarketPosition == 0 Then{ if PositionProfit(1) < 0 Then Vol = MaxContracts(1)*2; Else vol = 1; } #상향돌파 if crossup(var1,var2) Then{ T = 1; EE = C; cond[0] = false; for cnt = 1 to 4{ cond[cnt] = cond[cnt-1][1]; } } #하향이탈 if CrossDown(var1,var2) Then{ T = -1; EE = C; cond[0] = false; for cnt = 1 to 4{ cond[cnt] = cond[cnt-1][1]; } } #상향돌파후 P1혹은 P2틱이상 상승했으면 cond[0]은 true로 변경 if T == 1 Then{ if stime >= ST1 and stime < ST2 Then{ if H >= EE+PriceScale*P1 Then cond[0] = true; } Else{ if H >= EE+PriceScale*P2 Then cond[0] = true; } } #하향이탈후 P1혹은 P2틱이상 하락했으면 cond[0]은 true로 변경 if T == -1 Then{ if stime >= ST1 and stime < ST2 Then{ if L <= EE-PriceScale*P1 Then cond[0] = true; } Else{ if L <= EE-PriceScale*P2 Then cond[0] = true; } } #상향돌파 if crossup(var1,var2) Then{ cross = cross+ 1; if MarketPosition == 0 and cond[1] == false and cond[2] == false Then buy("B",OnClose,def,1); #매도진입후 매수로 스위칭 될때는 1계약 추가, 최대 N개약까지 if MarketPosition == -1 and cond[1] == false and cond[2] == false and cross >= 2 and MaxContracts < N Then buy("sbuy",OnClose,def,CurrentContracts+1); } #하향이탈 if CrossDown(var1,var2) Then{ cross = cross +1; if MarketPosition == 0 and cond[1] == false and cond[2] == false Then sell("S",OnClose,def,1); #매수진입후 매도로 스위칭 될때는 1계약 추가, 최대 N개약까지 if MarketPosition == 1 and cond[1] == false and cond[2] == false and cross >= 2 and MaxContracts < N Then sell("bsell",OnClose,def,CurrentContracts+1); } if MarketPosition == 1 Then{ if stime >= ST1 and stime < ST2 Then{ exitlong("BL1",AtStop,EntryPrice-PriceScale*L1); exitlong("BP1",AtLimit,EntryPrice+PriceScale*P1); } Else{ exitlong("BL2",AtStop,EntryPrice-PriceScale*L2); exitlong("BP2",AtLimit,EntryPrice+PriceScale*P2); } } if MarketPosition == -1 Then{ if stime >= ST1 and stime < ST2 Then{ ExitShort("SL1",AtStop,EntryPrice+PriceScale*L1); ExitShort("SP1",AtLimit,EntryPrice-PriceScale*P1); } Else{ ExitShort("SL2",AtStop,EntryPrice+PriceScale*L2); ExitShort("SP2",AtLimit,EntryPrice-PriceScale*P2); } }
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2016-07-27 13:22:06

안녕하세요 예스스탁입니다. 수익청산으로 청산될때만 2번쉬고 1계약으로 진입하게 수정했습니다. 손실청산이면 직전거래수량+1계약으로 다음크로스에 바로 진입합니다. input : L1(15),P1(15),L2(20),P2(20),N(5); Var : cross(0),vol(0),T(0),EE(0),cnt(0); var1 = ma(c,5); var2 = ma(c,20); #상향돌파 if crossup(var1,var2) Then{ cross = cross+ 1; #차트 첫 3번째 if cross == 3 Then buy("b",OnClose,def,1); #매도진입후 매수로 스위칭 될때는 1계약 추가, 최대 N개약까지 if MarketPosition == -1 and cross >= 4 and MaxContracts < N Then buy("sb",OnClose,def,CurrentContracts+1); #수익청산후 2번쉬고 3번째 진입 if MarketPosition == 0 and MarketPosition(1) == -1 and (IsExitName("SP1",1) or IsExitName("SP2",1)) and countif(crossup(var1,var2),BarsSinceExit(1)) == 2 and cross >= 4 Then buy("b1",OnClose,def,1); #손실청산후 1계약 추가 진입 if MarketPosition == 0 and MarketPosition(1) == -1 and (IsExitName("SL1",1) or IsExitName("SL2",1)) and cross >= 4 Then buy("b2",OnClose,def,MaxContracts(1)+1); } #하향이탈 if CrossDown(var1,var2) Then{ cross = cross +1; #차트 첫 3번째 if cross == 3 Then sell("s",OnClose,def,1); #매수진입후 매도로 스위칭 될때는 1계약 추가, 최대 N개약까지 if MarketPosition == 1 and cross >= 4 and MaxContracts < N Then sell("bs",OnClose,def,CurrentContracts+1); #청산후 2번쉬고 3번째 진입 if MarketPosition == 0 and MarketPosition(1) == 1 and (IsExitName("BP1",1) or IsExitName("BP2",1)) and countif(CrossDown(var1,var2),BarsSinceExit(1)) == 2 and cross >= 4 Then sell("s1",OnClose,def,1); #손실청산후 1계약 추가 진입 if MarketPosition == 0 and MarketPosition(1) == 1 and (IsExitName("BL1",1) or IsExitName("BL2",1)) and cross >= 4 Then Sell("S2",OnClose,def,MaxContracts(1)+1); } if MarketPosition == 1 Then{ if stime >= 80000 and stime < 153000 Then{ ExitLong("BL1",AtStop,EntryPrice-PriceScale*L1); ExitLong("BP1",AtLimit,EntryPrice+PriceScale*P1); } Else{ ExitLong("BL2",AtStop,EntryPrice-PriceScale*L2); ExitLong("BP2",AtLimit,EntryPrice+PriceScale*P2); } } if MarketPosition == -1 Then{ if stime >= 80000 and stime < 153000 Then{ ExitShort("SL1",AtStop,EntryPrice+PriceScale*L1); ExitShort("SP1",AtLimit,EntryPrice-PriceScale*P1); } Else{ ExitShort("SL2",AtStop,EntryPrice+PriceScale*L2); ExitShort("SP2",AtLimit,EntryPrice-PriceScale*P2); } } 즐거운 하루되세요 > 쿠루드 님이 쓴 글입니다. > 제목 : 문의드립니다 > 안녕하세요 문의를 통해 아래와 같이 수식을 변경했는데 진입은 원하는대로 구현이 됩니다 한가지만 수정 보완 부탁드립니다 목표틱인 p1, p2에 도달했을때만 새로운 진입이 돼야 하는데.. 로스컷인 L1, L2에 도달했을때도 추가 스위칭 하지 않고 새로운 진입을 합니다 이부분만 보완 부탁합니다 감사합니다 -------------------------------------------------------------------------------------- input : period1(5),period2(20),ST1(80000),ST2(153000),L1(20),P1(15),L2(25),P2(20),N(5); Var : cross(0),vol(0),T(0),EE(0),cnt(0); Array : cond[5](false); var1 = ma(c,period1); var2 = ma(c,period2); if MarketPosition != 0 Then{ if PositionProfit < 0 Then Vol = MaxContracts*2; Else vol = 1; } if MarketPosition == 0 Then{ if PositionProfit(1) < 0 Then Vol = MaxContracts(1)*2; Else vol = 1; } #상향돌파 if crossup(var1,var2) Then{ T = 1; EE = C; cond[0] = false; for cnt = 1 to 4{ cond[cnt] = cond[cnt-1][1]; } } #하향이탈 if CrossDown(var1,var2) Then{ T = -1; EE = C; cond[0] = false; for cnt = 1 to 4{ cond[cnt] = cond[cnt-1][1]; } } #상향돌파후 P1혹은 P2틱이상 상승했으면 cond[0]은 true로 변경 if T == 1 Then{ if stime >= ST1 and stime < ST2 Then{ if H >= EE+PriceScale*P1 Then cond[0] = true; } Else{ if H >= EE+PriceScale*P2 Then cond[0] = true; } } #하향이탈후 P1혹은 P2틱이상 하락했으면 cond[0]은 true로 변경 if T == -1 Then{ if stime >= ST1 and stime < ST2 Then{ if L <= EE-PriceScale*P1 Then cond[0] = true; } Else{ if L <= EE-PriceScale*P2 Then cond[0] = true; } } #상향돌파 if crossup(var1,var2) Then{ cross = cross+ 1; if MarketPosition == 0 and cond[1] == false and cond[2] == false Then buy("B",OnClose,def,1); #매도진입후 매수로 스위칭 될때는 1계약 추가, 최대 N개약까지 if MarketPosition == -1 and cond[1] == false and cond[2] == false and cross >= 2 and MaxContracts < N Then buy("sbuy",OnClose,def,CurrentContracts+1); } #하향이탈 if CrossDown(var1,var2) Then{ cross = cross +1; if MarketPosition == 0 and cond[1] == false and cond[2] == false Then sell("S",OnClose,def,1); #매수진입후 매도로 스위칭 될때는 1계약 추가, 최대 N개약까지 if MarketPosition == 1 and cond[1] == false and cond[2] == false and cross >= 2 and MaxContracts < N Then sell("bsell",OnClose,def,CurrentContracts+1); } if MarketPosition == 1 Then{ if stime >= ST1 and stime < ST2 Then{ exitlong("BL1",AtStop,EntryPrice-PriceScale*L1); exitlong("BP1",AtLimit,EntryPrice+PriceScale*P1); } Else{ exitlong("BL2",AtStop,EntryPrice-PriceScale*L2); exitlong("BP2",AtLimit,EntryPrice+PriceScale*P2); } } if MarketPosition == -1 Then{ if stime >= ST1 and stime < ST2 Then{ ExitShort("SL1",AtStop,EntryPrice+PriceScale*L1); ExitShort("SP1",AtLimit,EntryPrice-PriceScale*P1); } Else{ ExitShort("SL2",AtStop,EntryPrice+PriceScale*L2); ExitShort("SP2",AtLimit,EntryPrice-PriceScale*P2); } }