커뮤니티

수식수정

프로필 이미지
바나
2017-03-20 16:16:19
97
글번호 107977
답변완료
1. 현재 3번까지 매수할수있고 퍼센트에 따라 분할매도 하게 되어있는데요. 총3번까지 매수하였으나 -3퍼 밑으로 빠지면 매도하게 바꾸고 싶은데 어떻게 설정해야 할지 잘 모르겠네요.. 2. 투자금액의 퍼센트 별로 분할매수 하되, 1,2,3 번 매수 방식을 바꿀수도 있나요? 바꿀수있다면 샘플로 수식을 주실수 있으신지요? 3. 동일봉 내에서 매수매도가 여러번 이루어지지 않게 하기 위해 BarsSinceExit수식을 넣었는데 제대로 작동안하는거 같네요.. 예를들어 10주 익절함과 동시에 동일가격에 10주매수하는 경우가 생깁니다. 수식수정좀 부탁드립니다.. Input : 투자금액(1000000),Period(20), MultiD(2), short(12),long(26),sig(9),VP(20),P1(5),P2(24), 시작일(20170320),시작시간(90000); INPUT : LENGTH(10); var : MAv(0),e(0),x(0),cnt(0),count(0),Tcond(false); VAR : TCHAN(0), BCHAN(0),T1(0),T2(0); var : MACDV(0),MACDS(0),MACDO(0),Vma(0),Cma1(0),Cma2(0); var : HH(0),Bxcond1(false),Bxcond2(false),Bxcond3(false); var : LL(0),Sxcond1(false),Sxcond2(false),Sxcond3(false); Array : VV[5](0),XX[5](0); MAv = ma(C,Period); MACDV = MACD(Short,long); MACDS = ema(MACDV,sig); MACDO = MACDV-MACDS; Vma = ma(v,VP); Cma1 = ma(C,P1); Cma2 = ma(C,P2); TCHAN = HIGHEST(HIGH, LENGTH)[1]; BCHAN = LOWEST(LOW, LENGTH)[1]; vv[0] = floor((투자금액*0.2)/C); vv[1] = floor((투자금액*0.3)/C); vv[2] = floor((투자금액*0.5)/C); if sdate >= 시작일 and stime >= 시작시간 Then Tcond = true; if Tcond == true then{ if (TotalTrades == 0 or MarketPosition == 0 and BarsSinceExit(1) > 2) then{ if MarketPosition == 0 and C >=dayclose(1) and MACDO > 0 and C > O and V >= Vma*1.5 and Cma1 >Cma2 and e < 3 and stime < 150000 Then buy("b",atmarket,def,vv[MaxEntries]); if MarketPosition == 1 Then{ if CurrentContracts > CurrentContracts[1] Then{ e = e +1; if e == 1 then XX[e] = CurrentContracts; Else XX[e] = CurrentContracts-CurrentContracts[1]; } if MarketPosition == 1 and C >=dayclose(1) and MACDO > 0 and C > O and V >= Vma*1.5 and Cma1 >Cma2 and e < 3 and stime < 150000 Then buy("bb",atmarket,def,vv[MaxEntries]); } Else{ e = 0; X = 0; }} if MarketPosition == 1 then{ HH = highest(H,BarsSinceEntry); if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx1" Then Bxcond1 = true; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx2" Then Bxcond2 = true; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx3" Then Bxcond3 = true; if Bxcond1 == false and HH >= EntryPrice*1.03 and HH < EntryPrice*1.05 Then ExitLong("Bx1",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(1/5)),1); if Bxcond2 == false and HH >= EntryPrice*1.05 and HH < EntryPrice*1.08 Then ExitLong("Bx2",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(2/5)),1); if Bxcond3 == false and HH >= EntryPrice*1.08 Then ExitLong("Bx3",AtStop,HH-(HH-EntryPrice)*0.1); } Else{ Bxcond1 = false; Bxcond2 = false; Bxcond3 = false; } if MarketPosition == -1 then{ LL = Lowest(L,BarsSinceEntry); if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Sx1" Then Sxcond1 = true; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Sx2" Then Sxcond2 = true; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Sx3" Then Sxcond3 = true; if Sxcond1 == false and LL <= EntryPrice*0.98 and LL < EntryPrice*0.97 Then ExitShort("Sx1",AtStop,LL+(EntryPrice-LL)*0.3,"",Floor(MaxContracts*(1/3)),1); if Sxcond2 == false and LL <= EntryPrice*0.97 and LL < EntryPrice*0.96 Then ExitShort("Sx2",AtStop,LL+(EntryPrice-LL)*0.3,"",Floor(MaxContracts*(1/3)),1); if Sxcond3 == false and LL <= EntryPrice*0.93 Then ExitShort("Sx3",AtStop,LL+(EntryPrice-LL)*0.3); } Else{ Sxcond1 = false; Sxcond2 = false; Sxcond3 = false; }}
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2017-03-21 11:11:44

안녕하세요 예스스탁입니다. 1. Input : 투자금액(10000000),Period(20), MultiD(2), short(12),long(26),sig(9),VP(20),P1(5),P2(24), 시작일(20170320),시작시간(90000); Input : LENGTH(10),loss(3); var : MAv(0),e(0),x(0),cnt(0),count(0),Tcond(false); Var : TCHAN(0), BCHAN(0),T1(0),T2(0); var : MACDV(0),MACDS(0),MACDO(0),Vma(0),Cma1(0),Cma2(0); var : HH(0),Bxcond1(false),Bxcond2(false),Bxcond3(false); var : LL(0),Sxcond1(false),Sxcond2(false),Sxcond3(false); Array : VV[5](0),XX[5](0); MAv = ma(C,Period); MACDV = MACD(Short,long); MACDS = ema(MACDV,sig); MACDO = MACDV-MACDS; Vma = ma(v,VP); Cma1 = ma(C,P1); Cma2 = ma(C,P2); TCHAN = HIGHEST(HIGH, LENGTH)[1]; BCHAN = LOWEST(LOW, LENGTH)[1]; vv[0] = floor((투자금액*0.2)/C); vv[1] = floor((투자금액*0.3)/C); vv[2] = floor((투자금액*0.5)/C); if sdate >= 시작일 and stime >= 시작시간 Then Tcond = true; if Tcond == true then{ if (TotalTrades == 0 or MarketPosition == 0 and BarsSinceExit(1) > 2) then{ if MarketPosition == 0 and C >=dayclose(1) and MACDO > 0 and C > O and V >= Vma*1.5 and Cma1 >Cma2 and stime < 150000 Then buy("b",atmarket,def,vv[MaxEntries]); } if MarketPosition == 1 Then{ if CurrentContracts > CurrentContracts[1] Then{ e = e +1; if e == 1 then XX[e] = CurrentContracts; Else XX[e] = CurrentContracts-CurrentContracts[1]; } #두번째 매수 if MarketPosition == 1 and e < 3 and C >=dayclose(1) and MACDO > 0 and C > O and V >= Vma*1.5 and Cma1 >Cma2 and stime < 150000 Then{ buy("bb",atmarket,def,vv[MaxEntries]); } HH = highest(H,BarsSinceEntry); if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx1" Then Bxcond1 = true; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx2" Then Bxcond2 = true; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx3" Then Bxcond3 = true; if Bxcond1 == false and HH >= EntryPrice*1.03 and HH < EntryPrice*1.05 Then ExitLong("Bx1",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(1/5)),1); if Bxcond2 == false and HH >= EntryPrice*1.05 and HH < EntryPrice*1.08 Then ExitLong("Bx2",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(2/5)),1); if Bxcond3 == false and HH >= EntryPrice*1.08 Then ExitLong("Bx3",AtStop,HH-(HH-EntryPrice)*0.1); #3번 매수후 평단가-3%면 전량 매도 if MaxEntries == 3 Then ExitLong("bl",AtStop,AvgEntryPrice*(1-loss/100)); } Else{ e = 0; X = 0; Bxcond1 = false; Bxcond2 = false; Bxcond3 = false; } } 2 Input : 투자금액(10000000),Period(20), MultiD(2), short(12),long(26),sig(9),VP(20),P1(5),P2(24), 시작일(20170320),시작시간(90000); Input : LENGTH(10),loss(3); var : MAv(0),e(0),x(0),cnt(0),count(0),Tcond(false); Var : TCHAN(0), BCHAN(0),T1(0),T2(0); var : MACDV(0),MACDS(0),MACDO(0),Vma(0),Cma1(0),Cma2(0); var : HH(0),Bxcond1(false),Bxcond2(false),Bxcond3(false); var : LL(0),Sxcond1(false),Sxcond2(false),Sxcond3(false); Array : VV[5](0),XX[5](0); MAv = ma(C,Period); MACDV = MACD(Short,long); MACDS = ema(MACDV,sig); MACDO = MACDV-MACDS; Vma = ma(v,VP); Cma1 = ma(C,P1); Cma2 = ma(C,P2); TCHAN = HIGHEST(HIGH, LENGTH)[1]; BCHAN = LOWEST(LOW, LENGTH)[1]; vv[0] = floor((투자금액*0.2)/C); vv[1] = floor((투자금액*0.3)/C); vv[2] = floor((투자금액*0.5)/C); if sdate >= 시작일 and stime >= 시작시간 Then Tcond = true; if Tcond == true then{ if (TotalTrades == 0 or MarketPosition == 0 and BarsSinceExit(1) > 2) then{ if MarketPosition == 0 and C >=dayclose(1) and MACDO > 0 and C > O and V >= Vma*1.5 and Cma1 >Cma2 and stime < 150000 Then buy("b1",atmarket,def,vv[MaxEntries]); } if MarketPosition == 1 Then{ if CurrentContracts > CurrentContracts[1] Then{ e = e +1; if e == 1 then XX[e] = CurrentContracts; Else XX[e] = CurrentContracts-CurrentContracts[1]; } #두번째 매수 if MarketPosition == 1 and e == 1 and C >=dayclose(1) and MACDO > 0 and C > O and V >= Vma*1.5 and Cma1 >Cma2 and stime < 150000 Then{ buy("b2",atmarket,def,vv[MaxEntries]); } #세번재매수 if MarketPosition == 1 and e == 2 and C >=dayclose(1) and MACDO > 0 and C > O and V >= Vma*1.5 and Cma1 >Cma2 and stime < 150000 Then{ buy("b3",atmarket,def,vv[MaxEntries]); } HH = highest(H,BarsSinceEntry); if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx1" Then Bxcond1 = true; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx2" Then Bxcond2 = true; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx3" Then Bxcond3 = true; if Bxcond1 == false and HH >= EntryPrice*1.03 and HH < EntryPrice*1.05 Then ExitLong("Bx1",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(1/5)),1); if Bxcond2 == false and HH >= EntryPrice*1.05 and HH < EntryPrice*1.08 Then ExitLong("Bx2",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(2/5)),1); if Bxcond3 == false and HH >= EntryPrice*1.08 Then ExitLong("Bx3",AtStop,HH-(HH-EntryPrice)*0.1); #3번 매수후 평단가-3%면 전량 매도 if MaxEntries == 3 Then ExitLong("bl",AtStop,AvgEntryPrice*(1-loss/100)); } Else{ e = 0; X = 0; Bxcond1 = false; Bxcond2 = false; Bxcond3 = false; } } 3 해당부분은 피라미딩 진입과 청산이 동일시점에 동시충족되는 부분입니다. 청산이 봉미완성시에 발생하므로 수식에서 조건체크가 되지 않습니다. 즐거운 하루되세요 > 바나 님이 쓴 글입니다. > 제목 : 수식수정 > 1. 현재 3번까지 매수할수있고 퍼센트에 따라 분할매도 하게 되어있는데요. 총3번까지 매수하였으나 -3퍼 밑으로 빠지면 매도하게 바꾸고 싶은데 어떻게 설정해야 할지 잘 모르겠네요.. 2. 투자금액의 퍼센트 별로 분할매수 하되, 1,2,3 번 매수 방식을 바꿀수도 있나요? 바꿀수있다면 샘플로 수식을 주실수 있으신지요? 3. 동일봉 내에서 매수매도가 여러번 이루어지지 않게 하기 위해 BarsSinceExit수식을 넣었는데 제대로 작동안하는거 같네요.. 예를들어 10주 익절함과 동시에 동일가격에 10주매수하는 경우가 생깁니다. 수식수정좀 부탁드립니다.. Input : 투자금액(1000000),Period(20), MultiD(2), short(12),long(26),sig(9),VP(20),P1(5),P2(24), 시작일(20170320),시작시간(90000); INPUT : LENGTH(10); var : MAv(0),e(0),x(0),cnt(0),count(0),Tcond(false); VAR : TCHAN(0), BCHAN(0),T1(0),T2(0); var : MACDV(0),MACDS(0),MACDO(0),Vma(0),Cma1(0),Cma2(0); var : HH(0),Bxcond1(false),Bxcond2(false),Bxcond3(false); var : LL(0),Sxcond1(false),Sxcond2(false),Sxcond3(false); Array : VV[5](0),XX[5](0); MAv = ma(C,Period); MACDV = MACD(Short,long); MACDS = ema(MACDV,sig); MACDO = MACDV-MACDS; Vma = ma(v,VP); Cma1 = ma(C,P1); Cma2 = ma(C,P2); TCHAN = HIGHEST(HIGH, LENGTH)[1]; BCHAN = LOWEST(LOW, LENGTH)[1]; vv[0] = floor((투자금액*0.2)/C); vv[1] = floor((투자금액*0.3)/C); vv[2] = floor((투자금액*0.5)/C); if sdate >= 시작일 and stime >= 시작시간 Then Tcond = true; if Tcond == true then{ if (TotalTrades == 0 or MarketPosition == 0 and BarsSinceExit(1) > 2) then{ if MarketPosition == 0 and C >=dayclose(1) and MACDO > 0 and C > O and V >= Vma*1.5 and Cma1 >Cma2 and e < 3 and stime < 150000 Then buy("b",atmarket,def,vv[MaxEntries]); if MarketPosition == 1 Then{ if CurrentContracts > CurrentContracts[1] Then{ e = e +1; if e == 1 then XX[e] = CurrentContracts; Else XX[e] = CurrentContracts-CurrentContracts[1]; } if MarketPosition == 1 and C >=dayclose(1) and MACDO > 0 and C > O and V >= Vma*1.5 and Cma1 >Cma2 and e < 3 and stime < 150000 Then buy("bb",atmarket,def,vv[MaxEntries]); } Else{ e = 0; X = 0; }} if MarketPosition == 1 then{ HH = highest(H,BarsSinceEntry); if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx1" Then Bxcond1 = true; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx2" Then Bxcond2 = true; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx3" Then Bxcond3 = true; if Bxcond1 == false and HH >= EntryPrice*1.03 and HH < EntryPrice*1.05 Then ExitLong("Bx1",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(1/5)),1); if Bxcond2 == false and HH >= EntryPrice*1.05 and HH < EntryPrice*1.08 Then ExitLong("Bx2",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(2/5)),1); if Bxcond3 == false and HH >= EntryPrice*1.08 Then ExitLong("Bx3",AtStop,HH-(HH-EntryPrice)*0.1); } Else{ Bxcond1 = false; Bxcond2 = false; Bxcond3 = false; } if MarketPosition == -1 then{ LL = Lowest(L,BarsSinceEntry); if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Sx1" Then Sxcond1 = true; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Sx2" Then Sxcond2 = true; if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Sx3" Then Sxcond3 = true; if Sxcond1 == false and LL <= EntryPrice*0.98 and LL < EntryPrice*0.97 Then ExitShort("Sx1",AtStop,LL+(EntryPrice-LL)*0.3,"",Floor(MaxContracts*(1/3)),1); if Sxcond2 == false and LL <= EntryPrice*0.97 and LL < EntryPrice*0.96 Then ExitShort("Sx2",AtStop,LL+(EntryPrice-LL)*0.3,"",Floor(MaxContracts*(1/3)),1); if Sxcond3 == false and LL <= EntryPrice*0.93 Then ExitShort("Sx3",AtStop,LL+(EntryPrice-LL)*0.3); } Else{ Sxcond1 = false; Sxcond2 = false; Sxcond3 = false; }}