커뮤니티

체크좀 부탁드림니다. ( 손절/익절발생후 5시간 지난후 정상매매되게 해주세요)

프로필 이미지
이형지
2018-10-29 12:11:01
175
글번호 123142
답변완료

첨부 이미지

아래수식에서는 손절또는 익절발생시 1000봉후에 진입이 되도록 수식되어 있는것으로 알고 있는데요.. Condition1 = MarketPosition == 0 and ExitDate(1) == sdate and (IsExitName("StopLoss",1) or IsExitName("StopProfitTarget",1)) and TimeToMinutes(stime) <= TimeToMinutes(ExitTime(1))+P6; 그런데 위 차트를 보시면 매수청산후 얼마지나지않아 매수가 되어버렸네요... 혹시 뭐가 잘못된건가요?? 제 의도는 손절/익절발생시 30봉인기준 5시간지난후 조건 충족시 진입되는 식을 구현하고 싶어요 =================================================================================== input : P1(-0.5),P2(0.9),P4(-0.2),P5(0.2),N1(20),N2(100),P6(1000),starttime(230000),endtime(140000),P7(1.3),P8(0.4); input : 손절틱수(62),익절틱수(85); var : cnt(0),sum1(0),sum2(0),avg1(0),avg2(0),T(0),mav2(0),mav3(0); var : sum3(0),Tcond(false); Condition1 = MarketPosition == 0 and ExitDate(1) == sdate and (IsExitName("StopLoss",1) or IsExitName("StopProfitTarget",1)) and TimeToMinutes(stime) <= TimeToMinutes(ExitTime(1))+P6; #설정 if sdate != sdate[1] then SetStopEndofday(endtime); if (sdate != sdate[1] and stime >= starttime) or (sdate == sdate[1] and stime >= starttime and stime[1] < starttime) then { Tcond = true; SetStopEndofday(0);#해제 } if (sdate != sdate[1] and stime >= endtime) or (sdate == sdate[1] and stime >= endtime and stime[1] < endtime) then { Tcond = false; } if DayClose(N2) > 0 Then { sum1 = 0; sum2 = 0; for cnt = 0 to N2-1 { if cnt < N1 Then sum1 = sum1 + DayClose(cnt); if cnt < N2 Then sum2 = sum2 + DayClose(cnt+1); } avg1 = sum1/N1; avg2 = sum2/N2; T = 0; if avg1 >= avg2 Then T = 1; if avg1 < avg2 Then T = -1; if T == 1 Then mav2=p2 ; if T == -1 Then mav2=p5; if T == 1 Then mav3=p1 ; if T == -1 Then mav3=p4 ; sum3 = 0; for cnt = 1 to 20 { sum3 = sum3 + (DayHigh(cnt)-DayLow(cnt)); } value1 = sum3/20 ; If MarketPosition == 0 and C >= (dayopen+value1*mav3) and c<c[1] and Condition1 == false Then { Buy("매수"); } if MaxEntries == 1 and MarketPosition == 1 Then { buy("추가매수",atlimit,EntryPrice-P7); } If MarketPosition == 0 and C <= (dayopen-value1*mav2) and c>c[1] and Condition1 == false Then { sell("매도"); } if MaxEntries == 1 and MarketPosition == -1 Then { Sell("추가매도",atlimit,EntryPrice+P8); } } SetStopLoss(PriceScale*손절틱수,PointStop); SetStopProfittarget(PriceScale*익절틱수,PointStop);
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2018-10-29 17:01:48

안녕하세요 예스스탁입니다. TimeToMinutes(stime)은 밤 0시 기준으로 봉의 시간을 분으로 환산해서 리턴해주는 함수입니다. 해당 기준으로 영업시간 기준으로 변경해 드리기에도 초기화를 해야하는 시점이 애매합니다. 해당 수식을 봉수로 제어되게 변경해 드립니다. 지정한 이름의 청산이 발생하면 P6개봉 이후에 진입하게 됩니다. input : P1(-0.5),P2(0.9),P4(-0.2),P5(0.2),N1(20),N2(100),P6(10),starttime(230000),endtime(140000),P7(1.3),P8(0.4); input : 손절틱수(62),익절틱수(85); var : cnt(0),sum1(0),sum2(0),avg1(0),avg2(0),T(0),mav2(0),mav3(0); var : sum3(0),Tcond(false); #설정 if sdate != sdate[1] then SetStopEndofday(endtime); if (sdate != sdate[1] and stime >= starttime) or (sdate == sdate[1] and stime >= starttime and stime[1] < starttime) then { Tcond = true; SetStopEndofday(0);#해제 Condition1 = false; } if TotalTrades > TotalTrades[1] and (IsExitName("StopLoss",1) or IsExitName("StopProfitTarget",1)) Then Condition1 = true; if Condition1 == true and BarsSinceExit(1) >= P6 Then Condition1 = false; if (sdate != sdate[1] and stime >= endtime) or (sdate == sdate[1] and stime >= endtime and stime[1] < endtime) then { Tcond = false; } if DayClose(N2) > 0 Then { sum1 = 0; sum2 = 0; for cnt = 0 to N2-1 { if cnt < N1 Then sum1 = sum1 + DayClose(cnt); if cnt < N2 Then sum2 = sum2 + DayClose(cnt+1); } avg1 = sum1/N1; avg2 = sum2/N2; T = 0; if avg1 >= avg2 Then T = 1; if avg1 < avg2 Then T = -1; if T == 1 Then mav2=p2 ; if T == -1 Then mav2=p5; if T == 1 Then mav3=p1 ; if T == -1 Then mav3=p4 ; sum3 = 0; for cnt = 1 to 20 { sum3 = sum3 + (DayHigh(cnt)-DayLow(cnt)); } value1 = sum3/20 ; If MarketPosition == 0 and C >= (dayopen+value1*mav3) and c<c[1] and Condition1 == false Then { Buy("매수"); } if MaxEntries == 1 and MarketPosition == 1 Then { buy("추가매수",atlimit,EntryPrice-P7); } If MarketPosition == 0 and C <= (dayopen-value1*mav2) and c>c[1] and Condition1 == false Then { sell("매도"); } if MaxEntries == 1 and MarketPosition == -1 Then { Sell("추가매도",atlimit,EntryPrice+P8); } } SetStopLoss(PriceScale*손절틱수,PointStop); SetStopProfittarget(PriceScale*익절틱수,PointStop); 즐거운 하루되세요 > 이형지 님이 쓴 글입니다. > 제목 : 체크좀 부탁드림니다. ( 손절/익절발생후 5시간 지난후 정상매매되게 해주세요) > 아래수식에서는 손절또는 익절발생시 1000봉후에 진입이 되도록 수식되어 있는것으로 알고 있는데요.. Condition1 = MarketPosition == 0 and ExitDate(1) == sdate and (IsExitName("StopLoss",1) or IsExitName("StopProfitTarget",1)) and TimeToMinutes(stime) <= TimeToMinutes(ExitTime(1))+P6; 그런데 위 차트를 보시면 매수청산후 얼마지나지않아 매수가 되어버렸네요... 혹시 뭐가 잘못된건가요?? 제 의도는 손절/익절발생시 30봉인기준 5시간지난후 조건 충족시 진입되는 식을 구현하고 싶어요 =================================================================================== input : P1(-0.5),P2(0.9),P4(-0.2),P5(0.2),N1(20),N2(100),P6(1000),starttime(230000),endtime(140000),P7(1.3),P8(0.4); input : 손절틱수(62),익절틱수(85); var : cnt(0),sum1(0),sum2(0),avg1(0),avg2(0),T(0),mav2(0),mav3(0); var : sum3(0),Tcond(false); Condition1 = MarketPosition == 0 and ExitDate(1) == sdate and (IsExitName("StopLoss",1) or IsExitName("StopProfitTarget",1)) and TimeToMinutes(stime) <= TimeToMinutes(ExitTime(1))+P6; #설정 if sdate != sdate[1] then SetStopEndofday(endtime); if (sdate != sdate[1] and stime >= starttime) or (sdate == sdate[1] and stime >= starttime and stime[1] < starttime) then { Tcond = true; SetStopEndofday(0);#해제 } if (sdate != sdate[1] and stime >= endtime) or (sdate == sdate[1] and stime >= endtime and stime[1] < endtime) then { Tcond = false; } if DayClose(N2) > 0 Then { sum1 = 0; sum2 = 0; for cnt = 0 to N2-1 { if cnt < N1 Then sum1 = sum1 + DayClose(cnt); if cnt < N2 Then sum2 = sum2 + DayClose(cnt+1); } avg1 = sum1/N1; avg2 = sum2/N2; T = 0; if avg1 >= avg2 Then T = 1; if avg1 < avg2 Then T = -1; if T == 1 Then mav2=p2 ; if T == -1 Then mav2=p5; if T == 1 Then mav3=p1 ; if T == -1 Then mav3=p4 ; sum3 = 0; for cnt = 1 to 20 { sum3 = sum3 + (DayHigh(cnt)-DayLow(cnt)); } value1 = sum3/20 ; If MarketPosition == 0 and C >= (dayopen+value1*mav3) and c<c[1] and Condition1 == false Then { Buy("매수"); } if MaxEntries == 1 and MarketPosition == 1 Then { buy("추가매수",atlimit,EntryPrice-P7); } If MarketPosition == 0 and C <= (dayopen-value1*mav2) and c>c[1] and Condition1 == false Then { sell("매도"); } if MaxEntries == 1 and MarketPosition == -1 Then { Sell("추가매도",atlimit,EntryPrice+P8); } } SetStopLoss(PriceScale*손절틱수,PointStop); SetStopProfittarget(PriceScale*익절틱수,PointStop);