커뮤니티

문의 드립니다.

프로필 이미지
에리카
2021-10-20 14:00:06
804
글번호 153025
답변완료

첨부 이미지

어제 골드 데모하는 중에 손절 처리가 이상하게 되었습니다. 손절은 15틱인데 55틱 손절이 되었습니다. 거래내용과 수식 올려드리니 어느 부분에 문제가 있는지 확인 부탁드립니다. input : StartTime(205500),EndTime(221000); input : Length(20), D1(2); input : 익절(20),손절(15),익절연속횟수(3),손절연속횟수(2); var : Tcond(false),profit(0),loss(0); if (sdate != sdate[1] and stime >= EndTime) or (sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then Tcond = False; if (sdate != sdate[1] and stime >= StartTime) or (sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then { Tcond = true; profit = 0; loss = 0; } if TotalTrades > TotalTrades[1] Then { if IsExitName("bp.",1) or IsExitName("bp",1) or IsExitName("sp.",1) or IsExitName("sp",1) Then profit = profit+1; Else profit = 0; if IsExitName("bl.",1) or IsExitName("bl",1) or IsExitName("sl.",1) or IsExitName("sl",1) Then loss = loss+1; Else loss = 0; } var1 = BollBandUp(Length,D1); var2 = BollBandDown(Length,D1); if Tcond == true Then { If CrossUP(H,var1) and c > o and profit < 익절연속횟수 and loss < 손절연속횟수 then { Buy("b",OnClose,DEF,1); ExitLong("bp.",AtLimit,C+PriceScale*익절,"",1,1); ExitLong("bl.",AtStop,C-PriceScale*손절,"",1,1); } If CrossDown(L,Var2) and C < O and profit < 익절연속횟수 and loss < 손절연속횟수 then { Sell("s",OnClose,DEF,1); ExitShort("sp.",AtLimit,C-PriceScale*익절,"",1,1); ExitShort("sl.",AtStop,C+PriceScale*손절,"",1,1); }} if MarketPosition == 1 Then { ExitLong("bp",AtLimit,EntryPrice+PriceScale*익절,"",1,1); ExitLong("bl",AtStop,EntryPrice-PriceScale*손절,"",1,1); } if MarketPosition == -1 Then { ExitShort("sp",AtLimit,EntryPrice-PriceScale*익절,"",1,1); ExitShort("sl",AtStop,EntryPrice+PriceScale*손절,"",1,1); } IF Endtime > starttime Then SetStopEndofday(Endtime); Else { 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 { IF Endtime <= starttime Then { SetStopEndofday(0); }}
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2021-10-20 16:15:54

안녕하세요 예스스탁입니다. 1 당일청산인 SetStopEndofday 함수가 실시간에서는 지정한 시간이후의 첫시세가 들어오면 즉시 청산이 됩니다. 2 하지만 [과거봉의 시뮬레이션]에서는 봉내부의 모든 시간을 알수가 없어 지정한 청산시간이 포함된 봉의 종가에 신호를 표시하고 해당 봉에는 다른 진입이나 청산이 발생하지 못하게 되어 있습니다. 다른 진입이나 청산신호를 막는것은 당일청산신호와의 발생순서를 명확히 규정하기 어렵기 때문입니다. 청산시간을 221000이 아닌 221500으로 변경해 보시면 청산시간과 해당봉이 겹치지 않아 손절이 발생하는 것을 확인하실수 있습니다. 3 해당 로직을 실제로 실시간에서 트레이딩을 하게 되면 청산시간이 221000이므로 손절까지도 가지않고 해당봉의 시가가 221000에 총족되므로 시가에서 바로 청산이 발생하게 됩니다. 5 해당 부분은 랭귀지의 시뮬레이션 체계라 수식에서 당일청산 함수를 변경할수는 없습니다. 실전 트레이딩에서 봉미완성시라도 시간조건 충족되면 청산하게 당일청산 함수를 사용했지만 해당 함수로 인해 과거 시뮬레이션시에 동일봉에 신호가 발생하는 것을 막는것을 피하고 싶으시면 아래와 같이 당일청산을 사용하지 않고 if문으로 시간을 지정해 종가에 청산을 하게 하시면 손절나오는 것을 보실수 있습니다. 아래식으로 시뮬레이션하시고 실전에서는 당일청산을 이용해 트레이딩하셔도 됩니다. 6 input : StartTime(205500),EndTime(221000); input : Length(20), D1(2); input : 익절(20),손절(15),익절연속횟수(3),손절연속횟수(2); var : Tcond(false),profit(0),loss(0); if (sdate != sdate[1] and stime >= EndTime) or (sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then { Tcond = False; if MarketPosition == 1 Then ExitLong("bx"); if MarketPosition == -1 Then ExitShort("sx"); } if (sdate != sdate[1] and stime >= StartTime) or (sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then { Tcond = true; profit = 0; loss = 0; } if TotalTrades > TotalTrades[1] Then { if IsExitName("bp.",1) or IsExitName("bp",1) or IsExitName("sp.",1) or IsExitName("sp",1) Then profit = profit+1; Else profit = 0; if IsExitName("bl.",1) or IsExitName("bl",1) or IsExitName("sl.",1) or IsExitName("sl",1) Then loss = loss+1; Else loss = 0; } var1 = BollBandUp(Length,D1); var2 = BollBandDown(Length,D1); if Tcond == true Then { If CrossUP(H,var1) and c > o and profit < 익절연속횟수 and loss < 손절연속횟수 then { Buy("b",OnClose,DEF,1); ExitLong("bp.",AtLimit,C+PriceScale*익절,"",1,1); ExitLong("bl.",AtStop,C-PriceScale*손절,"",1,1); } If CrossDown(L,Var2) and C < O and profit < 익절연속횟수 and loss < 손절연속횟수 then { Sell("s",OnClose,DEF,1); ExitShort("sp.",AtLimit,C-PriceScale*익절,"",1,1); ExitShort("sl.",AtStop,C+PriceScale*손절,"",1,1); }} if MarketPosition == 1 Then { ExitLong("bp",AtLimit,EntryPrice+PriceScale*익절,"",1,1); ExitLong("bl",AtStop,EntryPrice-PriceScale*손절,"",1,1); } if MarketPosition == -1 Then { ExitShort("sp",AtLimit,EntryPrice-PriceScale*익절,"",1,1); ExitShort("sl",AtStop,EntryPrice+PriceScale*손절,"",1,1); } 즐거운 하루되세요 > 에리카 님이 쓴 글입니다. > 제목 : 문의 드립니다. > 어제 골드 데모하는 중에 손절 처리가 이상하게 되었습니다. 손절은 15틱인데 55틱 손절이 되었습니다. 거래내용과 수식 올려드리니 어느 부분에 문제가 있는지 확인 부탁드립니다. input : StartTime(205500),EndTime(221000); input : Length(20), D1(2); input : 익절(20),손절(15),익절연속횟수(3),손절연속횟수(2); var : Tcond(false),profit(0),loss(0); if (sdate != sdate[1] and stime >= EndTime) or (sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then Tcond = False; if (sdate != sdate[1] and stime >= StartTime) or (sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then { Tcond = true; profit = 0; loss = 0; } if TotalTrades > TotalTrades[1] Then { if IsExitName("bp.",1) or IsExitName("bp",1) or IsExitName("sp.",1) or IsExitName("sp",1) Then profit = profit+1; Else profit = 0; if IsExitName("bl.",1) or IsExitName("bl",1) or IsExitName("sl.",1) or IsExitName("sl",1) Then loss = loss+1; Else loss = 0; } var1 = BollBandUp(Length,D1); var2 = BollBandDown(Length,D1); if Tcond == true Then { If CrossUP(H,var1) and c > o and profit < 익절연속횟수 and loss < 손절연속횟수 then { Buy("b",OnClose,DEF,1); ExitLong("bp.",AtLimit,C+PriceScale*익절,"",1,1); ExitLong("bl.",AtStop,C-PriceScale*손절,"",1,1); } If CrossDown(L,Var2) and C < O and profit < 익절연속횟수 and loss < 손절연속횟수 then { Sell("s",OnClose,DEF,1); ExitShort("sp.",AtLimit,C-PriceScale*익절,"",1,1); ExitShort("sl.",AtStop,C+PriceScale*손절,"",1,1); }} if MarketPosition == 1 Then { ExitLong("bp",AtLimit,EntryPrice+PriceScale*익절,"",1,1); ExitLong("bl",AtStop,EntryPrice-PriceScale*손절,"",1,1); } if MarketPosition == -1 Then { ExitShort("sp",AtLimit,EntryPrice-PriceScale*익절,"",1,1); ExitShort("sl",AtStop,EntryPrice+PriceScale*손절,"",1,1); } IF Endtime > starttime Then SetStopEndofday(Endtime); Else { 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 { IF Endtime <= starttime Then { SetStopEndofday(0); }}