커뮤니티

수식 의뢰 부탁드립니다.

프로필 이미지
산이보리
2021-04-22 23:59:14
918
글번호 148294
답변완료

첨부 이미지

안녕하세요 1. 아래 수식에서 3연속 손실이 발생할 경우 N분 매매정지를 할 수 있도록 수정 부탁드립니다 2. 그리고 매매가 끝나면 지정한 시간만큼 매매중지되어야 하는데 위 그림처럼 포지션 청산되자마자 다시 진입과 청산이 이루어집니다 항상 감사합니다 input : N(4),익절(0.03),손절(0),진입(10),StartTime(070000),EndTime(070000),매매정지(20),lb(0),lp(2),sb(0),sp(-2); var : LL(0),HH(0),tx1(0),tx2(0),cnt(0),Tx3(0),sum(0),CL(0),CS(0); Array : VV[20](0); var : Tcond(false),S1(0),D1(0),TM(0),b_vv(0),Condition4(False),최고점(0),최저점(0); Condition1 = L[4]>L[3] and L[3] >L[2] and H>H[1] and H[1]>H[2]; Condition2 = H[4]<H[3] and H[3]<H[2] and L<L[1] and L[1]<L[2]; if ( ( var2 == 0 and C > CS and vv[0] == -1 ) or LL == 0 or C > CL ) and condition1 == true and Condition1[1] == False Then { var1 = var1+1; LL = L[2]; CL = C; VV[0] = 1; For cnt = 1 to 19 { VV[cnt] = VV[cnt-1][1]; } if VV[N-1] != 0 Then { sum = 0; For cnt = 0 to N-1 { sum = sum + VV[cnt]; } } } else { if L < LL Then { var1 = 0; } } if (( var1 == 0 and C < CL and vv[0] ==1) or hh == 0 or C < CS) and condition2 == true and Condition2[1] == False Then { var2 = var2+1; HH = H[2]; CS = C; VV[0] = -1; For cnt = 1 to 19 { VV[cnt] = VV[cnt-1][1]; } if VV[N-1] != 0 Then { sum = 0; For cnt = 0 to N-1 { sum = sum + VV[cnt]; } } } Else { if H > HH Then { var2 = 0; } } #전봉과 현재봉의 영업일이 다르면 당일청산조건 if Bdate != Bdate[1] Then { S1 = TimeToMinutes(stime); D1 = sdate; Condition4 = False; } if D1 > 0 then { if sdate == D1 Then TM = TimeToMinutes(stime)-S1; Else TM = TimeToMinutes(stime)+1440-S1; } if TotalTrades > TotalTrades[1] Then { Condition4 = False; if IsExitName("xl",1) == true or IsExitName("xs",1) == true or IsExitName("stopprofittarget",1) == true then Condition4 = true; } b_vv = vv[4]+vv[3]+vv[2]+vv[1]; 최고점 = highest(h,진입); 최저점 = lowest(l,진입); if sTime > starttime or sTime < Endtime and marketposition == 0 Then { if (b_vv == lb and sum == lp) Then { if condition4 == False Then Buy("b"); if (condition4 == true and TM >= TM[BarsSinceExit(1)]+매매정지) Then Buy("b1"); } if (b_vv == sb and sum == sp) Then { if condition4 == False Then Sell("s"); if (condition4 == true and TM >= TM[BarsSinceExit(1)]+매매정지) Then Sell("s1"); } } if MarketPosition(0) > 0 and C < LL Then ExitLong("xl"); if MarketPosition(0) < 0 and C > HH Then ExitShort("xs"); #타겟청산 SetStopProfittarget(익절,pointstop); SetStopLoss( 손절 ,PointStop);
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2021-04-23 09:45:44

안녕하세요 예스스탁입니다. 1 if sTime > starttime or sTime < Endtime and marketposition == 0 Then if문에 or와 and가 같이 사용되면 ()로 우선순위를 지정해 주셔야 합니다. 작성하신 식은 marketposition == 0이 stime < Endtime에만 속하게 되어 매매정지가 제대로 동작하지 않습니다. 아래와 같이 시간제한 조건을 ()로 묶어주셔야 신호가 항상 무포지션에만 동작하게 됩니다. if (sTime > starttime or sTime < Endtime) and marketposition == 0 Then 기존식을 청산후 매매정지 이후에 다시 신호가 발생하게 간단히 수정하면 아래와 같습니다. input : N(4),익절(0.03),손절(0),진입(10),StartTime(070000),EndTime(070000),매매정지(20),lb(0),lp(2),sb(0),sp(-2); var : LL(0),HH(0),tx1(0),tx2(0),cnt(0),Tx3(0),sum(0),CL(0),CS(0); Array : VV[20](0); var : Tcond(false),S1(0),D1(0),TM(0),b_vv(0),Condition4(False),최고점(0),최저점(0),Lss(0),XTM(0); Condition1 = L[4]>L[3] and L[3] >L[2] and H>H[1] and H[1]>H[2]; Condition2 = H[4]<H[3] and H[3]<H[2] and L<L[1] and L[1]<L[2]; if ( ( var2 == 0 and C > CS and vv[0] == -1 ) or LL == 0 or C > CL ) and condition1 == true and Condition1[1] == False Then { var1 = var1+1; LL = L[2]; CL = C; VV[0] = 1; For cnt = 1 to 19 { VV[cnt] = VV[cnt-1][1]; } if VV[N-1] != 0 Then { sum = 0; For cnt = 0 to N-1 { sum = sum + VV[cnt]; } } } else { if L < LL Then { var1 = 0; } } if (( var1 == 0 and C < CL and vv[0] ==1) or hh == 0 or C < CS) and condition2 == true and Condition2[1] == False Then { var2 = var2+1; HH = H[2]; CS = C; VV[0] = -1; For cnt = 1 to 19 { VV[cnt] = VV[cnt-1][1]; } if VV[N-1] != 0 Then { sum = 0; For cnt = 0 to N-1 { sum = sum + VV[cnt]; } } } Else { if H > HH Then { var2 = 0; } } #전봉과 현재봉의 영업일이 다르면 당일청산조건 if Bdate != Bdate[1] Then { S1 = TimeToMinutes(stime); D1 = sdate; Condition4 = False; Lss = 0; XTM = 0; } if D1 > 0 then { if sdate == D1 Then TM = TimeToMinutes(stime)-S1; Else TM = TimeToMinutes(stime)+1440-S1; } if TotalTrades > TotalTrades[1] Then { if PositionProfit(1) < 0 Then Lss = Lss+1; Else Lss= 0; XTM = TM[BarsSinceExit(1)]; } b_vv = vv[4]+vv[3]+vv[2]+vv[1]; 최고점 = highest(h,진입); 최저점 = lowest(l,진입); if (sTime > starttime or sTime < Endtime) and marketposition == 0 and TM >= XTM+매매정지 Then { if (b_vv == lb and sum == lp) Then { Buy("b"); } if (b_vv == sb and sum == sp) Then { Sell("s"); } } if MarketPosition(0) > 0 and C < LL Then ExitLong("xl"); if MarketPosition(0) < 0 and C > HH Then ExitShort("xs"); #타겟청산 SetStopProfittarget(익절,pointstop); SetStopLoss( 손절 ,PointStop); 2 3연속 손실시에만 매매정지후 진입은 아래와 같습니다. input : N(4),익절(0.03),손절(0),진입(10),StartTime(070000),EndTime(070000),매매정지(20),lb(0),lp(2),sb(0),sp(-2); var : LL(0),HH(0),tx1(0),tx2(0),cnt(0),Tx3(0),sum(0),CL(0),CS(0); Array : VV[20](0); var : Tcond(false),S1(0),D1(0),TM(0),b_vv(0),Condition4(False),최고점(0),최저점(0),Lss(0),XTM(0); Condition1 = L[4]>L[3] and L[3] >L[2] and H>H[1] and H[1]>H[2]; Condition2 = H[4]<H[3] and H[3]<H[2] and L<L[1] and L[1]<L[2]; if ( ( var2 == 0 and C > CS and vv[0] == -1 ) or LL == 0 or C > CL ) and condition1 == true and Condition1[1] == False Then { var1 = var1+1; LL = L[2]; CL = C; VV[0] = 1; For cnt = 1 to 19 { VV[cnt] = VV[cnt-1][1]; } if VV[N-1] != 0 Then { sum = 0; For cnt = 0 to N-1 { sum = sum + VV[cnt]; } } } else { if L < LL Then { var1 = 0; } } if (( var1 == 0 and C < CL and vv[0] ==1) or hh == 0 or C < CS) and condition2 == true and Condition2[1] == False Then { var2 = var2+1; HH = H[2]; CS = C; VV[0] = -1; For cnt = 1 to 19 { VV[cnt] = VV[cnt-1][1]; } if VV[N-1] != 0 Then { sum = 0; For cnt = 0 to N-1 { sum = sum + VV[cnt]; } } } Else { if H > HH Then { var2 = 0; } } #전봉과 현재봉의 영업일이 다르면 당일청산조건 if Bdate != Bdate[1] Then { S1 = TimeToMinutes(stime); D1 = sdate; Condition4 = False; Lss = 0; XTM = 0; } if D1 > 0 then { if sdate == D1 Then TM = TimeToMinutes(stime)-S1; Else TM = TimeToMinutes(stime)+1440-S1; } if TotalTrades > TotalTrades[1] Then { if PositionProfit(1) < 0 Then Lss = Lss+1; Else Lss= 0; if Lss == 3 Then { XTM = TM[BarsSinceExit(1)]; } } b_vv = vv[4]+vv[3]+vv[2]+vv[1]; 최고점 = highest(h,진입); 최저점 = lowest(l,진입); if (sTime > starttime or sTime < Endtime) and marketposition == 0 and TM >= XTM+매매정지 Then { if (b_vv == lb and sum == lp) Then { Buy("b"); } if (b_vv == sb and sum == sp) Then { Sell("s"); } } if MarketPosition(0) > 0 and C < LL Then ExitLong("xl"); if MarketPosition(0) < 0 and C > HH Then ExitShort("xs"); #타겟청산 SetStopProfittarget(익절,pointstop); SetStopLoss( 손절 ,PointStop); 즐거운 하루되세요 > 산이보리 님이 쓴 글입니다. > 제목 : 수식 의뢰 부탁드립니다. > 안녕하세요 1. 아래 수식에서 3연속 손실이 발생할 경우 N분 매매정지를 할 수 있도록 수정 부탁드립니다 2. 그리고 매매가 끝나면 지정한 시간만큼 매매중지되어야 하는데 위 그림처럼 포지션 청산되자마자 다시 진입과 청산이 이루어집니다 항상 감사합니다 input : N(4),익절(0.03),손절(0),진입(10),StartTime(070000),EndTime(070000),매매정지(20),lb(0),lp(2),sb(0),sp(-2); var : LL(0),HH(0),tx1(0),tx2(0),cnt(0),Tx3(0),sum(0),CL(0),CS(0); Array : VV[20](0); var : Tcond(false),S1(0),D1(0),TM(0),b_vv(0),Condition4(False),최고점(0),최저점(0); Condition1 = L[4]>L[3] and L[3] >L[2] and H>H[1] and H[1]>H[2]; Condition2 = H[4]<H[3] and H[3]<H[2] and L<L[1] and L[1]<L[2]; if ( ( var2 == 0 and C > CS and vv[0] == -1 ) or LL == 0 or C > CL ) and condition1 == true and Condition1[1] == False Then { var1 = var1+1; LL = L[2]; CL = C; VV[0] = 1; For cnt = 1 to 19 { VV[cnt] = VV[cnt-1][1]; } if VV[N-1] != 0 Then { sum = 0; For cnt = 0 to N-1 { sum = sum + VV[cnt]; } } } else { if L < LL Then { var1 = 0; } } if (( var1 == 0 and C < CL and vv[0] ==1) or hh == 0 or C < CS) and condition2 == true and Condition2[1] == False Then { var2 = var2+1; HH = H[2]; CS = C; VV[0] = -1; For cnt = 1 to 19 { VV[cnt] = VV[cnt-1][1]; } if VV[N-1] != 0 Then { sum = 0; For cnt = 0 to N-1 { sum = sum + VV[cnt]; } } } Else { if H > HH Then { var2 = 0; } } #전봉과 현재봉의 영업일이 다르면 당일청산조건 if Bdate != Bdate[1] Then { S1 = TimeToMinutes(stime); D1 = sdate; Condition4 = False; } if D1 > 0 then { if sdate == D1 Then TM = TimeToMinutes(stime)-S1; Else TM = TimeToMinutes(stime)+1440-S1; } if TotalTrades > TotalTrades[1] Then { Condition4 = False; if IsExitName("xl",1) == true or IsExitName("xs",1) == true or IsExitName("stopprofittarget",1) == true then Condition4 = true; } b_vv = vv[4]+vv[3]+vv[2]+vv[1]; 최고점 = highest(h,진입); 최저점 = lowest(l,진입); if sTime > starttime or sTime < Endtime and marketposition == 0 Then { if (b_vv == lb and sum == lp) Then { if condition4 == False Then Buy("b"); if (condition4 == true and TM >= TM[BarsSinceExit(1)]+매매정지) Then Buy("b1"); } if (b_vv == sb and sum == sp) Then { if condition4 == False Then Sell("s"); if (condition4 == true and TM >= TM[BarsSinceExit(1)]+매매정지) Then Sell("s1"); } } if MarketPosition(0) > 0 and C < LL Then ExitLong("xl"); if MarketPosition(0) < 0 and C > HH Then ExitShort("xs"); #타겟청산 SetStopProfittarget(익절,pointstop); SetStopLoss( 손절 ,PointStop);