커뮤니티

문의 드립니다.~~~~

프로필 이미지
예스요
2021-11-11 12:56:37
940
글번호 153523
답변완료
아래와 같이 답을 주셨는데 실행을 해 보니 의도대로 되지 않고 청산과 재진입이 과다 실행이 되어 다시 문의 드립니다,~~ 1,진입은 추세 진입식으로 2,트레일링 추세익절청산과 동시에 재진입, 추세손절과 동시에 재진입으로 부탁드립니다. 정확한 수식을 위해 답변 주신 수식 위에 있는 변수와 시간조건식을 같이 올립니다. input : 진입틱수(20); input : 최소손실틱(0),손실감소틱(20); input : StartTime1(70000),EndTime1(53000); input : StartTime2(99999999),EndTime2(99999999); input : StartTime3(99999999),EndTime3(99999999); input : StartTime4(99999999),EndTime4(99999999); var : Tcond(false); var : OO(0),HH(0),LL(0); if (sdate != sdate[1] and stime >= EndTime1) or (sdate == sdate[1] and stime >= EndTime1 and stime[1] < EndTime1) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime1) or (sdate == sdate[1] and stime >= StartTime1 and stime[1] < StartTime1) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime2) or (sdate == sdate[1] and stime >= EndTime2 and stime[1] < EndTime2) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime2) or (sdate == sdate[1] and stime >= StartTime2 and stime[1] < StartTime2) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime3) or (sdate == sdate[1] and stime >= EndTime3 and stime[1] < EndTime3) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime3) or (sdate == sdate[1] and stime >= StartTime3 and stime[1] < StartTime3) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime4) or (sdate == sdate[1] and stime >= EndTime4 and stime[1] < EndTime4) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime4) or (sdate == sdate[1] and stime >= StartTime4 and stime[1] < StartTime4) Then { Tcond = true; OO = O; HH = H; LL = L; } if Tcond == true Then { if MarketPosition == 0 and OO > 0 and LL > OO-PriceScale*진입틱수 Then Buy("시작매수",AtStop,LL+PriceScale*진입틱수); if MarketPosition == 0 and OO > 0 and HH < OO+PriceScale*진입틱수 Then Sell("시작매도",AtStop,HH-PriceScale*진입틱수); } if MarketPosition == 1 Then { if Tcond == true Then Sell("Bl1",AtStop,EntryPrice-PriceScale*진입틱수); Else Exitlong("Bl2",AtLimit,EntryPrice-PriceScale*진입틱수); if highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*최소손실틱 Then { if Tcond == true Then Sell("sx1",AtLimit,highest(H,BarsSinceEntry)-PriceScale*손실감소틱); Else ExitLong("sx2",AtLimit,highest(H,BarsSinceEntry)-PriceScale*손실감소틱); } } if MarketPosition == -1 Then { if Tcond == true Then Buy("sl1",AtStop,EntryPrice+PriceScale*진입틱수); Else ExitShort("sl2",AtStop,EntryPrice+PriceScale*진입틱수); if lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*최소손실틱 Then { if Tcond == true Then Buy("bx1",AtStop,lowest(L,BarsSinceEntry)+PriceScale*손실감소틱); Else ExitShort("bx2",AtLimit,Lowest(L,BarsSinceEntry)+PriceScale*손실감소틱); } }
시스템
답변 3
프로필 이미지

예스스탁 예스스탁 답변

2021-11-11 15:22:40

안녕하세요 예스스탁입니다. 신호타입이 반대로 된 부분이 있어 식을 수정했습니다. 지정한 StartTime이후의 최고가와 최저가를 계산하는 부분이 빠져있어 해당 부분도 추가했습니다. 불필요하신면 삭제하시기 바랍니다. input : 진입틱수(20); input : 최소손실틱(0),손실감소틱(20); input : StartTime1(70000),EndTime1(53000); input : StartTime2(99999999),EndTime2(99999999); input : StartTime3(99999999),EndTime3(99999999); input : StartTime4(99999999),EndTime4(99999999); var : Tcond(false); var : OO(0),HH(0),LL(0); if (sdate != sdate[1] and stime >= EndTime1) or (sdate == sdate[1] and stime >= EndTime1 and stime[1] < EndTime1) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime1) or (sdate == sdate[1] and stime >= StartTime1 and stime[1] < StartTime1) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime2) or (sdate == sdate[1] and stime >= EndTime2 and stime[1] < EndTime2) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime2) or (sdate == sdate[1] and stime >= StartTime2 and stime[1] < StartTime2) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime3) or (sdate == sdate[1] and stime >= EndTime3 and stime[1] < EndTime3) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime3) or (sdate == sdate[1] and stime >= StartTime3 and stime[1] < StartTime3) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime4) or (sdate == sdate[1] and stime >= EndTime4 and stime[1] < EndTime4) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime4) or (sdate == sdate[1] and stime >= StartTime4 and stime[1] < StartTime4) Then { Tcond = true; OO = O; HH = H; LL = L; } if Tcond == true Then { if L < LL Then LL = L; if H > HH Then HH = H; if MarketPosition == 0 and OO > 0 and LL > OO-PriceScale*진입틱수 Then Buy("시작매수",AtStop,LL+PriceScale*진입틱수); if MarketPosition == 0 and OO > 0 and HH < OO+PriceScale*진입틱수 Then Sell("시작매도",AtStop,HH-PriceScale*진입틱수); if MarketPosition == 1 Then { if Tcond == true Then Sell("Bl1",AtStop,EntryPrice-PriceScale*진입틱수); Else Exitlong("Bl2",AtStop,EntryPrice-PriceScale*진입틱수); if highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*최소손실틱 Then { if Tcond == true Then Sell("sx1",AtStop,highest(H,BarsSinceEntry)-PriceScale*손실감소틱); Else ExitLong("sx2",AtStop,highest(H,BarsSinceEntry)-PriceScale*손실감소틱); } } if MarketPosition == -1 Then { if Tcond == true Then Buy("sl1",AtStop,EntryPrice+PriceScale*진입틱수); Else ExitShort("sl2",AtStop,EntryPrice+PriceScale*진입틱수); if lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*최소손실틱 Then { if Tcond == true Then Buy("bx1",AtStop,lowest(L,BarsSinceEntry)+PriceScale*손실감소틱); Else ExitShort("bx2",AtStop,Lowest(L,BarsSinceEntry)+PriceScale*손실감소틱); } } } 즐거운 하루되세요 > 예스요 님이 쓴 글입니다. > 제목 : 문의 드립니다.~~~~ > 아래와 같이 답을 주셨는데 실행을 해 보니 의도대로 되지 않고 청산과 재진입이 과다 실행이 되어 다시 문의 드립니다,~~ 1,진입은 추세 진입식으로 2,트레일링 추세익절청산과 동시에 재진입, 추세손절과 동시에 재진입으로 부탁드립니다. 정확한 수식을 위해 답변 주신 수식 위에 있는 변수와 시간조건식을 같이 올립니다. input : 진입틱수(20); input : 최소손실틱(0),손실감소틱(20); input : StartTime1(70000),EndTime1(53000); input : StartTime2(99999999),EndTime2(99999999); input : StartTime3(99999999),EndTime3(99999999); input : StartTime4(99999999),EndTime4(99999999); var : Tcond(false); var : OO(0),HH(0),LL(0); if (sdate != sdate[1] and stime >= EndTime1) or (sdate == sdate[1] and stime >= EndTime1 and stime[1] < EndTime1) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime1) or (sdate == sdate[1] and stime >= StartTime1 and stime[1] < StartTime1) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime2) or (sdate == sdate[1] and stime >= EndTime2 and stime[1] < EndTime2) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime2) or (sdate == sdate[1] and stime >= StartTime2 and stime[1] < StartTime2) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime3) or (sdate == sdate[1] and stime >= EndTime3 and stime[1] < EndTime3) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime3) or (sdate == sdate[1] and stime >= StartTime3 and stime[1] < StartTime3) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime4) or (sdate == sdate[1] and stime >= EndTime4 and stime[1] < EndTime4) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime4) or (sdate == sdate[1] and stime >= StartTime4 and stime[1] < StartTime4) Then { Tcond = true; OO = O; HH = H; LL = L; } if Tcond == true Then { if MarketPosition == 0 and OO > 0 and LL > OO-PriceScale*진입틱수 Then Buy("시작매수",AtStop,LL+PriceScale*진입틱수); if MarketPosition == 0 and OO > 0 and HH < OO+PriceScale*진입틱수 Then Sell("시작매도",AtStop,HH-PriceScale*진입틱수); } if MarketPosition == 1 Then { if Tcond == true Then Sell("Bl1",AtStop,EntryPrice-PriceScale*진입틱수); Else Exitlong("Bl2",AtLimit,EntryPrice-PriceScale*진입틱수); if highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*최소손실틱 Then { if Tcond == true Then Sell("sx1",AtLimit,highest(H,BarsSinceEntry)-PriceScale*손실감소틱); Else ExitLong("sx2",AtLimit,highest(H,BarsSinceEntry)-PriceScale*손실감소틱); } } if MarketPosition == -1 Then { if Tcond == true Then Buy("sl1",AtStop,EntryPrice+PriceScale*진입틱수); Else ExitShort("sl2",AtStop,EntryPrice+PriceScale*진입틱수); if lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*최소손실틱 Then { if Tcond == true Then Buy("bx1",AtStop,lowest(L,BarsSinceEntry)+PriceScale*손실감소틱); Else ExitShort("bx2",AtLimit,Lowest(L,BarsSinceEntry)+PriceScale*손실감소틱); } }
프로필 이미지

예스요

2021-11-11 15:48:55

한가지만 추가 적용해 주시면 감사하겠습니다.~~~ <청산시> 1, 설정된 각 시간대 내에서는 청산 조건이 충족되면 수식 그대로 청산 및 스위칭 재진입 2, 설정된 각 시간내에서 청산 조건이 충족 되지 않아 포지션을 가지고 각 시간대를 지날때에는 청산 조건이 충족되면 스위칭 재진입 없이 청산만 이루어지도록 부탁드립니다~~~ > 예스스탁 님이 쓴 글입니다. > 제목 : Re : 문의 드립니다.~~~~ > 안녕하세요 예스스탁입니다. 신호타입이 반대로 된 부분이 있어 식을 수정했습니다. 지정한 StartTime이후의 최고가와 최저가를 계산하는 부분이 빠져있어 해당 부분도 추가했습니다. 불필요하신면 삭제하시기 바랍니다. input : 진입틱수(20); input : 최소손실틱(0),손실감소틱(20); input : StartTime1(70000),EndTime1(53000); input : StartTime2(99999999),EndTime2(99999999); input : StartTime3(99999999),EndTime3(99999999); input : StartTime4(99999999),EndTime4(99999999); var : Tcond(false); var : OO(0),HH(0),LL(0); if (sdate != sdate[1] and stime >= EndTime1) or (sdate == sdate[1] and stime >= EndTime1 and stime[1] < EndTime1) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime1) or (sdate == sdate[1] and stime >= StartTime1 and stime[1] < StartTime1) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime2) or (sdate == sdate[1] and stime >= EndTime2 and stime[1] < EndTime2) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime2) or (sdate == sdate[1] and stime >= StartTime2 and stime[1] < StartTime2) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime3) or (sdate == sdate[1] and stime >= EndTime3 and stime[1] < EndTime3) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime3) or (sdate == sdate[1] and stime >= StartTime3 and stime[1] < StartTime3) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime4) or (sdate == sdate[1] and stime >= EndTime4 and stime[1] < EndTime4) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime4) or (sdate == sdate[1] and stime >= StartTime4 and stime[1] < StartTime4) Then { Tcond = true; OO = O; HH = H; LL = L; } if Tcond == true Then { if L < LL Then LL = L; if H > HH Then HH = H; if MarketPosition == 0 and OO > 0 and LL > OO-PriceScale*진입틱수 Then Buy("시작매수",AtStop,LL+PriceScale*진입틱수); if MarketPosition == 0 and OO > 0 and HH < OO+PriceScale*진입틱수 Then Sell("시작매도",AtStop,HH-PriceScale*진입틱수); if MarketPosition == 1 Then { if Tcond == true Then Sell("Bl1",AtStop,EntryPrice-PriceScale*진입틱수); Else Exitlong("Bl2",AtStop,EntryPrice-PriceScale*진입틱수); if highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*최소손실틱 Then { if Tcond == true Then Sell("sx1",AtStop,highest(H,BarsSinceEntry)-PriceScale*손실감소틱); Else ExitLong("sx2",AtStop,highest(H,BarsSinceEntry)-PriceScale*손실감소틱); } } if MarketPosition == -1 Then { if Tcond == true Then Buy("sl1",AtStop,EntryPrice+PriceScale*진입틱수); Else ExitShort("sl2",AtStop,EntryPrice+PriceScale*진입틱수); if lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*최소손실틱 Then { if Tcond == true Then Buy("bx1",AtStop,lowest(L,BarsSinceEntry)+PriceScale*손실감소틱); Else ExitShort("bx2",AtStop,Lowest(L,BarsSinceEntry)+PriceScale*손실감소틱); } } } 즐거운 하루되세요 > 예스요 님이 쓴 글입니다. > 제목 : 문의 드립니다.~~~~ > 아래와 같이 답을 주셨는데 실행을 해 보니 의도대로 되지 않고 청산과 재진입이 과다 실행이 되어 다시 문의 드립니다,~~ 1,진입은 추세 진입식으로 2,트레일링 추세익절청산과 동시에 재진입, 추세손절과 동시에 재진입으로 부탁드립니다. 정확한 수식을 위해 답변 주신 수식 위에 있는 변수와 시간조건식을 같이 올립니다. input : 진입틱수(20); input : 최소손실틱(0),손실감소틱(20); input : StartTime1(70000),EndTime1(53000); input : StartTime2(99999999),EndTime2(99999999); input : StartTime3(99999999),EndTime3(99999999); input : StartTime4(99999999),EndTime4(99999999); var : Tcond(false); var : OO(0),HH(0),LL(0); if (sdate != sdate[1] and stime >= EndTime1) or (sdate == sdate[1] and stime >= EndTime1 and stime[1] < EndTime1) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime1) or (sdate == sdate[1] and stime >= StartTime1 and stime[1] < StartTime1) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime2) or (sdate == sdate[1] and stime >= EndTime2 and stime[1] < EndTime2) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime2) or (sdate == sdate[1] and stime >= StartTime2 and stime[1] < StartTime2) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime3) or (sdate == sdate[1] and stime >= EndTime3 and stime[1] < EndTime3) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime3) or (sdate == sdate[1] and stime >= StartTime3 and stime[1] < StartTime3) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime4) or (sdate == sdate[1] and stime >= EndTime4 and stime[1] < EndTime4) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime4) or (sdate == sdate[1] and stime >= StartTime4 and stime[1] < StartTime4) Then { Tcond = true; OO = O; HH = H; LL = L; } if Tcond == true Then { if MarketPosition == 0 and OO > 0 and LL > OO-PriceScale*진입틱수 Then Buy("시작매수",AtStop,LL+PriceScale*진입틱수); if MarketPosition == 0 and OO > 0 and HH < OO+PriceScale*진입틱수 Then Sell("시작매도",AtStop,HH-PriceScale*진입틱수); } if MarketPosition == 1 Then { if Tcond == true Then Sell("Bl1",AtStop,EntryPrice-PriceScale*진입틱수); Else Exitlong("Bl2",AtLimit,EntryPrice-PriceScale*진입틱수); if highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*최소손실틱 Then { if Tcond == true Then Sell("sx1",AtLimit,highest(H,BarsSinceEntry)-PriceScale*손실감소틱); Else ExitLong("sx2",AtLimit,highest(H,BarsSinceEntry)-PriceScale*손실감소틱); } } if MarketPosition == -1 Then { if Tcond == true Then Buy("sl1",AtStop,EntryPrice+PriceScale*진입틱수); Else ExitShort("sl2",AtStop,EntryPrice+PriceScale*진입틱수); if lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*최소손실틱 Then { if Tcond == true Then Buy("bx1",AtStop,lowest(L,BarsSinceEntry)+PriceScale*손실감소틱); Else ExitShort("bx2",AtLimit,Lowest(L,BarsSinceEntry)+PriceScale*손실감소틱); } }
프로필 이미지

예스스탁 예스스탁 답변

2021-11-11 15:55:14

안녕하세요 예스스탁입니다. input : 진입틱수(20); input : 최소손실틱(0),손실감소틱(20); input : StartTime1(70000),EndTime1(53000); input : StartTime2(99999999),EndTime2(99999999); input : StartTime3(99999999),EndTime3(99999999); input : StartTime4(99999999),EndTime4(99999999); var : Tcond(false); var : OO(0),HH(0),LL(0); if (sdate != sdate[1] and stime >= EndTime1) or (sdate == sdate[1] and stime >= EndTime1 and stime[1] < EndTime1) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime1) or (sdate == sdate[1] and stime >= StartTime1 and stime[1] < StartTime1) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime2) or (sdate == sdate[1] and stime >= EndTime2 and stime[1] < EndTime2) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime2) or (sdate == sdate[1] and stime >= StartTime2 and stime[1] < StartTime2) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime3) or (sdate == sdate[1] and stime >= EndTime3 and stime[1] < EndTime3) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime3) or (sdate == sdate[1] and stime >= StartTime3 and stime[1] < StartTime3) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime4) or (sdate == sdate[1] and stime >= EndTime4 and stime[1] < EndTime4) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime4) or (sdate == sdate[1] and stime >= StartTime4 and stime[1] < StartTime4) Then { Tcond = true; OO = O; HH = H; LL = L; } if Tcond == true Then { if L < LL Then LL = L; if H > HH Then HH = H; if MarketPosition == 0 and OO > 0 and LL > OO-PriceScale*진입틱수 Then Buy("시작매수",AtStop,LL+PriceScale*진입틱수); if MarketPosition == 0 and OO > 0 and HH < OO+PriceScale*진입틱수 Then Sell("시작매도",AtStop,HH-PriceScale*진입틱수); } if MarketPosition == 1 Then { if Tcond == true Then Sell("Bl1",AtStop,EntryPrice-PriceScale*진입틱수); Else Exitlong("Bl2",AtStop,EntryPrice-PriceScale*진입틱수); if highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*최소손실틱 Then { if Tcond == true Then Sell("sx1",AtStop,highest(H,BarsSinceEntry)-PriceScale*손실감소틱); Else ExitLong("sx2",AtStop,highest(H,BarsSinceEntry)-PriceScale*손실감소틱); } } if MarketPosition == -1 Then { if Tcond == true Then Buy("sl1",AtStop,EntryPrice+PriceScale*진입틱수); Else ExitShort("sl2",AtStop,EntryPrice+PriceScale*진입틱수); if lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*최소손실틱 Then { if Tcond == true Then Buy("bx1",AtStop,lowest(L,BarsSinceEntry)+PriceScale*손실감소틱); Else ExitShort("bx2",AtStop,Lowest(L,BarsSinceEntry)+PriceScale*손실감소틱); } } 즐거운 하루되세요 > 예스요 님이 쓴 글입니다. > 제목 : Re : Re : 문의 드립니다.~~~~ > 한가지만 추가 적용해 주시면 감사하겠습니다.~~~ <청산시> 1, 설정된 각 시간대 내에서는 청산 조건이 충족되면 수식 그대로 청산 및 스위칭 재진입 2, 설정된 각 시간내에서 청산 조건이 충족 되지 않아 포지션을 가지고 각 시간대를 지날때에는 청산 조건이 충족되면 스위칭 재진입 없이 청산만 이루어지도록 부탁드립니다~~~ > 예스스탁 님이 쓴 글입니다. > 제목 : Re : 문의 드립니다.~~~~ > 안녕하세요 예스스탁입니다. 신호타입이 반대로 된 부분이 있어 식을 수정했습니다. 지정한 StartTime이후의 최고가와 최저가를 계산하는 부분이 빠져있어 해당 부분도 추가했습니다. 불필요하신면 삭제하시기 바랍니다. input : 진입틱수(20); input : 최소손실틱(0),손실감소틱(20); input : StartTime1(70000),EndTime1(53000); input : StartTime2(99999999),EndTime2(99999999); input : StartTime3(99999999),EndTime3(99999999); input : StartTime4(99999999),EndTime4(99999999); var : Tcond(false); var : OO(0),HH(0),LL(0); if (sdate != sdate[1] and stime >= EndTime1) or (sdate == sdate[1] and stime >= EndTime1 and stime[1] < EndTime1) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime1) or (sdate == sdate[1] and stime >= StartTime1 and stime[1] < StartTime1) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime2) or (sdate == sdate[1] and stime >= EndTime2 and stime[1] < EndTime2) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime2) or (sdate == sdate[1] and stime >= StartTime2 and stime[1] < StartTime2) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime3) or (sdate == sdate[1] and stime >= EndTime3 and stime[1] < EndTime3) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime3) or (sdate == sdate[1] and stime >= StartTime3 and stime[1] < StartTime3) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime4) or (sdate == sdate[1] and stime >= EndTime4 and stime[1] < EndTime4) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime4) or (sdate == sdate[1] and stime >= StartTime4 and stime[1] < StartTime4) Then { Tcond = true; OO = O; HH = H; LL = L; } if Tcond == true Then { if L < LL Then LL = L; if H > HH Then HH = H; if MarketPosition == 0 and OO > 0 and LL > OO-PriceScale*진입틱수 Then Buy("시작매수",AtStop,LL+PriceScale*진입틱수); if MarketPosition == 0 and OO > 0 and HH < OO+PriceScale*진입틱수 Then Sell("시작매도",AtStop,HH-PriceScale*진입틱수); if MarketPosition == 1 Then { if Tcond == true Then Sell("Bl1",AtStop,EntryPrice-PriceScale*진입틱수); Else Exitlong("Bl2",AtStop,EntryPrice-PriceScale*진입틱수); if highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*최소손실틱 Then { if Tcond == true Then Sell("sx1",AtStop,highest(H,BarsSinceEntry)-PriceScale*손실감소틱); Else ExitLong("sx2",AtStop,highest(H,BarsSinceEntry)-PriceScale*손실감소틱); } } if MarketPosition == -1 Then { if Tcond == true Then Buy("sl1",AtStop,EntryPrice+PriceScale*진입틱수); Else ExitShort("sl2",AtStop,EntryPrice+PriceScale*진입틱수); if lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*최소손실틱 Then { if Tcond == true Then Buy("bx1",AtStop,lowest(L,BarsSinceEntry)+PriceScale*손실감소틱); Else ExitShort("bx2",AtStop,Lowest(L,BarsSinceEntry)+PriceScale*손실감소틱); } } } 즐거운 하루되세요 > 예스요 님이 쓴 글입니다. > 제목 : 문의 드립니다.~~~~ > 아래와 같이 답을 주셨는데 실행을 해 보니 의도대로 되지 않고 청산과 재진입이 과다 실행이 되어 다시 문의 드립니다,~~ 1,진입은 추세 진입식으로 2,트레일링 추세익절청산과 동시에 재진입, 추세손절과 동시에 재진입으로 부탁드립니다. 정확한 수식을 위해 답변 주신 수식 위에 있는 변수와 시간조건식을 같이 올립니다. input : 진입틱수(20); input : 최소손실틱(0),손실감소틱(20); input : StartTime1(70000),EndTime1(53000); input : StartTime2(99999999),EndTime2(99999999); input : StartTime3(99999999),EndTime3(99999999); input : StartTime4(99999999),EndTime4(99999999); var : Tcond(false); var : OO(0),HH(0),LL(0); if (sdate != sdate[1] and stime >= EndTime1) or (sdate == sdate[1] and stime >= EndTime1 and stime[1] < EndTime1) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime1) or (sdate == sdate[1] and stime >= StartTime1 and stime[1] < StartTime1) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime2) or (sdate == sdate[1] and stime >= EndTime2 and stime[1] < EndTime2) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime2) or (sdate == sdate[1] and stime >= StartTime2 and stime[1] < StartTime2) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime3) or (sdate == sdate[1] and stime >= EndTime3 and stime[1] < EndTime3) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime3) or (sdate == sdate[1] and stime >= StartTime3 and stime[1] < StartTime3) Then { Tcond = true; OO = O; HH = H; LL = L; } if (sdate != sdate[1] and stime >= EndTime4) or (sdate == sdate[1] and stime >= EndTime4 and stime[1] < EndTime4) Then { Tcond = False; } if (DayOfWeek(sDate) != 1 and sdate != sdate[1] and stime >= StartTime4) or (sdate == sdate[1] and stime >= StartTime4 and stime[1] < StartTime4) Then { Tcond = true; OO = O; HH = H; LL = L; } if Tcond == true Then { if MarketPosition == 0 and OO > 0 and LL > OO-PriceScale*진입틱수 Then Buy("시작매수",AtStop,LL+PriceScale*진입틱수); if MarketPosition == 0 and OO > 0 and HH < OO+PriceScale*진입틱수 Then Sell("시작매도",AtStop,HH-PriceScale*진입틱수); } if MarketPosition == 1 Then { if Tcond == true Then Sell("Bl1",AtStop,EntryPrice-PriceScale*진입틱수); Else Exitlong("Bl2",AtLimit,EntryPrice-PriceScale*진입틱수); if highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*최소손실틱 Then { if Tcond == true Then Sell("sx1",AtLimit,highest(H,BarsSinceEntry)-PriceScale*손실감소틱); Else ExitLong("sx2",AtLimit,highest(H,BarsSinceEntry)-PriceScale*손실감소틱); } } if MarketPosition == -1 Then { if Tcond == true Then Buy("sl1",AtStop,EntryPrice+PriceScale*진입틱수); Else ExitShort("sl2",AtStop,EntryPrice+PriceScale*진입틱수); if lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*최소손실틱 Then { if Tcond == true Then Buy("bx1",AtStop,lowest(L,BarsSinceEntry)+PriceScale*손실감소틱); Else ExitShort("bx2",AtLimit,Lowest(L,BarsSinceEntry)+PriceScale*손실감소틱); } }