커뮤니티

문의드립니다.

프로필 이미지
jesten77
2021-11-23 23:13:53
602
글번호 153860
답변완료
항상 감사드립니다. 아래 수식으로 데모를 해보니, 문제가 있어 확인 부탁드립니다. 1. 익절 횟수로 제한을 두었는데, 첫 거래가 bx 또는 cx 되었으면 익절횟수를 채울때까지 다음 조건이 맞으면 거래를 진행해야 하는데 거래가 추가로 이루어지지 않습니다. 2. bx, cx를 없애고 손절틱수를 지정해서 해보았는데요. 지정한 손절틱수에 손절되지 않는 경우도 있고 심지어 거래 종료시간에 청산되는 경우도 나옵니다. 익절횟수를 채우기까지 거래가 되지도 않습니다. 확인후 수정 부탁드립니다. 감사합니다. input : n1(n); input : StartTime(233000),EndTime(060000); input : 익절틱수(100),손절틱수(0),익절횟수(2); var : Tcond(false), entry(0); IF Endtime > starttime Then SetStopEndofday(Endtime); Else { if sDate != sDate[1] Then SetStopEndofday(Endtime); } if (NextBarSdate != sdate and NextBarStime >= EndTime) or (NextBarSdate == sdate and NextBarStime >= EndTime and stime < EndTime) Then Tcond = False; if (NextBarSdate != sdate and NextBarStime >= StartTime) or (NextBarSdate == sdate and NextBarStime >= StartTime and stime < StartTime) Then { Tcond = true; entry = 0; IF Endtime <= starttime Then { SetStopEndofday(0); } } if (MarketPosition != 0 and MarketPosition != MarketPosition[1]) or (MarketPosition == MarketPosition[1] and TotalTrades > TotalTrades[1]) Then entry = entry+1; if Tcond == true Then { if MarketPosition <= 0 and entry < 거래횟수 Then Buy("b1",AtStop,H[n1]+PriceScale*1); if MarketPosition >= 0 and entry < 거래횟수 Then Sell("s1",AtStop,L[N1]-PriceScale*1); if MarketPosition == 1 Then ExitLong("bx",AtStop,L[N1]-PriceScale*1); if MarketPosition == -1 Then ExitShort("sx",AtStop,H[n1]+PriceScale*1); } SetStopProfittarget(PriceScale*익절틱수,PointStop); SetStopLoss(PriceScale*손절틱수,PointStop);
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2021-11-24 14:07:52

안녕하세요 예스스탁입니다. input : n1(n); input : StartTime(233000),EndTime(060000); input : 익절틱수(100),손절틱수(0),익절횟수(2); var : Tcond(false), Profit(0); IF Endtime > starttime Then SetStopEndofday(Endtime); Else { if sDate != sDate[1] Then SetStopEndofday(Endtime); } if (NextBarSdate != sdate and NextBarStime >= EndTime) or (NextBarSdate == sdate and NextBarStime >= EndTime and stime < EndTime) Then Tcond = False; if (NextBarSdate != sdate and NextBarStime >= StartTime) or (NextBarSdate == sdate and NextBarStime >= StartTime and stime < StartTime) Then { Tcond = true; Profit = 0; IF Endtime <= starttime Then { SetStopEndofday(0); } } #익절청산 카운트 if TotalTrades > TotalTrades[1] and IsExitName("StopProfitTarget",1) == true Then Profit = profit+1; if Tcond == true Then { if MarketPosition <= 0 and Profit < 익절횟수 Then Buy("b1",AtStop,H[n1]+PriceScale*1); if MarketPosition >= 0 and Profit < 익절횟수 Then Sell("s1",AtStop,L[N1]-PriceScale*1); if MarketPosition == 1 Then ExitLong("bx",AtStop,L[N1]-PriceScale*1); if MarketPosition == -1 Then ExitShort("sx",AtStop,H[n1]+PriceScale*1); } SetStopProfittarget(PriceScale*익절틱수,PointStop); SetStopLoss(PriceScale*손절틱수,PointStop); 즐거운 하루되세요 > jesten77 님이 쓴 글입니다. > 제목 : 문의드립니다. > 항상 감사드립니다. 아래 수식으로 데모를 해보니, 문제가 있어 확인 부탁드립니다. 1. 익절 횟수로 제한을 두었는데, 첫 거래가 bx 또는 cx 되었으면 익절횟수를 채울때까지 다음 조건이 맞으면 거래를 진행해야 하는데 거래가 추가로 이루어지지 않습니다. 2. bx, cx를 없애고 손절틱수를 지정해서 해보았는데요. 지정한 손절틱수에 손절되지 않는 경우도 있고 심지어 거래 종료시간에 청산되는 경우도 나옵니다. 익절횟수를 채우기까지 거래가 되지도 않습니다. 확인후 수정 부탁드립니다. 감사합니다. input : n1(n); input : StartTime(233000),EndTime(060000); input : 익절틱수(100),손절틱수(0),익절횟수(2); var : Tcond(false), entry(0); IF Endtime > starttime Then SetStopEndofday(Endtime); Else { if sDate != sDate[1] Then SetStopEndofday(Endtime); } if (NextBarSdate != sdate and NextBarStime >= EndTime) or (NextBarSdate == sdate and NextBarStime >= EndTime and stime < EndTime) Then Tcond = False; if (NextBarSdate != sdate and NextBarStime >= StartTime) or (NextBarSdate == sdate and NextBarStime >= StartTime and stime < StartTime) Then { Tcond = true; entry = 0; IF Endtime <= starttime Then { SetStopEndofday(0); } } if (MarketPosition != 0 and MarketPosition != MarketPosition[1]) or (MarketPosition == MarketPosition[1] and TotalTrades > TotalTrades[1]) Then entry = entry+1; if Tcond == true Then { if MarketPosition <= 0 and entry < 거래횟수 Then Buy("b1",AtStop,H[n1]+PriceScale*1); if MarketPosition >= 0 and entry < 거래횟수 Then Sell("s1",AtStop,L[N1]-PriceScale*1); if MarketPosition == 1 Then ExitLong("bx",AtStop,L[N1]-PriceScale*1); if MarketPosition == -1 Then ExitShort("sx",AtStop,H[n1]+PriceScale*1); } SetStopProfittarget(PriceScale*익절틱수,PointStop); SetStopLoss(PriceScale*손절틱수,PointStop);