커뮤니티

수식 수정 부탁드립니다

프로필 이미지
산이보리
2021-04-26 09:07:19
1038
글번호 148373
답변완료
안녕하세요 아래 수식에 다음과 같은 내용을 추가부탁드립니다 1. 매수청산 후 매매정지, 매수조건이 다시 만족하면 매매 (sum이 '0' -> '+2'가 다시 될 때 매수해야하지만 현재 청산이후 연속 매수와 청산을 반복) 매도청산 후 매매정지, 매도조건이 다시 만족하면 매매 (sum이 '-2' -> '-2'가 다시 될 때 매도해야 하지만 현재 청산이후 연속 매도와 청산을 반복) 2. 3회 로스컷 후 매매정지, 다시 한번 손실나면 또 매매정지되는 문제점 해소 3회 로스컷 후 매매정지, 이후 손실 카운팅을 다시 시작으로 개선 항상 감사드립니다 -------------------- input : N(4),익절(0.03),손절(0),StartTime(070000),EndTime(070000),매매정지(20),lb(0),lp(2),sb(-2),sp(-2); var : LL(0),HH(0),cnt(0),sum(0),CL(0),CS(0),Lss(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 PositionProfit(1) < 0 Then Lss = Lss+1; Else Lss= 0; if lss == 3 Then Condition4 = true; } b_vv = vv[4]+vv[3]+vv[2]+vv[1]; 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 Then ExitLong("xl",atstop,ll); if MarketPosition(0) < 0 Then ExitShort("xs",atstop,hh); #타겟청산 SetStopProfittarget(익절,pointstop); SetStopLoss( 손절 ,PointStop);
시스템
답변 2
프로필 이미지

예스스탁 예스스탁 답변

2021-04-26 15:35:11

안녕하세요 예스스탁입니다. sum이 0선을 크로스한 후 1회만 진입, 3회로스컷 후 다시 3회를 카운트하게 수정했습니다. input : N(4),익절(0.03),손절(0),StartTime(070000),EndTime(070000),매매정지(20),lb(0),lp(2),sb(-2),sp(-2); var : LL(0),HH(0),cnt(0),sum(0),CL(0),CS(0),Lss(0),B(False),S(False); 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 PositionProfit(1) < 0 Then Lss = Lss+1; Else Lss = 0; if lss == 3 Then { Condition4 = true; Lss = 0; } } b_vv = vv[4]+vv[3]+vv[2]+vv[1]; if CrossUp(sum,0) Then B = true; if CrossDown(sum,0) Then S = true; if (sTime > starttime or sTime < Endtime) and marketposition == 0 Then { if (b_vv == lb and sum == lp) Then { if B == true and condition4 == False Then { Buy("b"); B = False; } if B == true and condition4 == true and TM >= TM[BarsSinceExit(1)]+매매정지 Then { Buy("b1"); B = False; } } if (b_vv == sb and sum == sp) Then { if S == true and condition4 == False Then { Sell("s"); S = False; } if S == true and condition4 == true and TM >= TM[BarsSinceExit(1)]+매매정지 Then { Sell("s1"); S = False; } } } if MarketPosition(0) > 0 Then ExitLong("xl",atstop,ll); if MarketPosition(0) < 0 Then ExitShort("xs",atstop,hh); #타겟청산 SetStopProfittarget(익절,pointstop); SetStopLoss( 손절 ,PointStop); 즐거운 하루되세요 > 산이보리 님이 쓴 글입니다. > 제목 : 수식 수정 부탁드립니다 > 안녕하세요 아래 수식에 다음과 같은 내용을 추가부탁드립니다 1. 매수청산 후 매매정지, 매수조건이 다시 만족하면 매매 (sum이 '0' -> '+2'가 다시 될 때 매수해야하지만 현재 청산이후 연속 매수와 청산을 반복) 매도청산 후 매매정지, 매도조건이 다시 만족하면 매매 (sum이 '-2' -> '-2'가 다시 될 때 매도해야 하지만 현재 청산이후 연속 매도와 청산을 반복) 2. 3회 로스컷 후 매매정지, 다시 한번 손실나면 또 매매정지되는 문제점 해소 3회 로스컷 후 매매정지, 이후 손실 카운팅을 다시 시작으로 개선 항상 감사드립니다 -------------------- input : N(4),익절(0.03),손절(0),StartTime(070000),EndTime(070000),매매정지(20),lb(0),lp(2),sb(-2),sp(-2); var : LL(0),HH(0),cnt(0),sum(0),CL(0),CS(0),Lss(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 PositionProfit(1) < 0 Then Lss = Lss+1; Else Lss= 0; if lss == 3 Then Condition4 = true; } b_vv = vv[4]+vv[3]+vv[2]+vv[1]; 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 Then ExitLong("xl",atstop,ll); if MarketPosition(0) < 0 Then ExitShort("xs",atstop,hh); #타겟청산 SetStopProfittarget(익절,pointstop); SetStopLoss( 손절 ,PointStop);
프로필 이미지

산이보리

2021-04-26 17:14:30

산이보리 님에 의해 삭제된 답변입니다.