커뮤니티

문의드립니다

프로필 이미지
jesten77
2021-11-23 19:12:38
567
글번호 153855
답변완료
친절한 도움에 항상 감사드립니다. 아래 수식에 다음 내용 추가 부탁드립니다. 1. 매수 매도 진입후 m 틱 이상 수익이 발생했으나 목표익절가에 도달하지 못하고 진입가격에 다시 내려올 때 m1 틱에서 익절 청산하는 수식. 2. 매수 매도 진입후 목표익절을 p1, p2 로 분할로 청산하는 수식. * 추가해 주신 수식에 주석 달아 주시면 좋겠습니다. 감사합니다. input : n1(n),n(n); input : StartTime(231000),EndTime(053000); input : 익절틱수(80),손절틱수(0), 거래횟수(10); var : Tcond(false), T(0), entry(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 { T = 0; Tcond = true; entry = 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 NextBarOpen <= Highest(H,n1) and entry < 거래횟수 Then Buy("b1",AtStop,Highest(H,n1)+PriceScale*1); if MarketPosition >= 0 and NextBarOpen >= Lowest(L,N1) and entry < 거래횟수 Then Sell("s1",AtStop,Lowest(L,N1)-PriceScale*1); if MarketPosition == 1 Then ExitLong("bx",AtStop,Lowest(L,n)[BarsSinceEntry]-PriceScale*1); if MarketPosition == -1 Then ExitShort("sx",AtStop,Highest(H,n)[BarsSinceEntry]+PriceScale*1); } SetStopProfittarget(PriceScale*익절틱수,PointStop); SetStopLoss(PriceScale*손절틱수,PointStop); 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-11-24 11:30:32

안녕하세요 예스스탁입니다. input : n1(n),n(n); input : StartTime(231000),EndTime(053000); input : 익절틱수1(80),익절틱수2(100),손절틱수(0), 거래횟수(10); input : mm(50),m1(10); var : Tcond(false), T(0), entry(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 { T = 0; Tcond = true; entry = 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 NextBarOpen <= Highest(H,n1) and entry < 거래횟수 Then Buy("b1",AtStop,Highest(H,n1)+PriceScale*1); if MarketPosition >= 0 and NextBarOpen >= Lowest(L,N1) and entry < 거래횟수 Then Sell("s1",AtStop,Lowest(L,N1)-PriceScale*1); if MarketPosition == 1 Then ExitLong("bx",AtStop,Lowest(L,n)[BarsSinceEntry]-PriceScale*1); if MarketPosition == -1 Then ExitShort("sx",AtStop,Highest(H,n)[BarsSinceEntry]+PriceScale*1); } SetStopLoss(PriceScale*손절틱수,PointStop); if MarketPosition == 1 Then { #익절1 절반청산 ExitLong("Bp1",AtLimit,EntryPrice+PriceScale*익절틱수1,"",max(1,Floor(MaxContracts/2)),1); #익절2 잔량 모두 청산 ExitLong("Bp2",AtLimit,EntryPrice+PriceScale*익절틱수2); #매수후 최고가가 진입가 대비 mm틱이상 상승했고(mm틱이상 수익발생한적이 있고) if Highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*mm Then ExitLong("btr",AtStop,EntryPrice+PriceScale*m1); #하락해서 진입가+m1틱까지 하락하면 청산 } #매도후 if MarketPosition == -1 Then { #익절1 절반청산 ExitShort("sp1",AtLimit,EntryPrice-PriceScale*익절틱수1,"",max(1,Floor(MaxContracts/2)),1); #익절2 잔량 모두 청산 ExitShort("sp2",AtLimit,EntryPrice-PriceScale*익절틱수2); #최저가가 진입가 대비 mm틱이상 하락했고(mm틱이상 수익발생한적이 있고) if lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*mm Then ExitShort("str",AtStop,EntryPrice-PriceScale*m1);#상승해서 진입가-m1틱까지 상승하면 청산 } 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); } } 즐거운 하루되세요 > jesten77 님이 쓴 글입니다. > 제목 : 문의드립니다 > 친절한 도움에 항상 감사드립니다. 아래 수식에 다음 내용 추가 부탁드립니다. 1. 매수 매도 진입후 m 틱 이상 수익이 발생했으나 목표익절가에 도달하지 못하고 진입가격에 다시 내려올 때 m1 틱에서 익절 청산하는 수식. 2. 매수 매도 진입후 목표익절을 p1, p2 로 분할로 청산하는 수식. * 추가해 주신 수식에 주석 달아 주시면 좋겠습니다. 감사합니다. input : n1(n),n(n); input : StartTime(231000),EndTime(053000); input : 익절틱수(80),손절틱수(0), 거래횟수(10); var : Tcond(false), T(0), entry(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 { T = 0; Tcond = true; entry = 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 NextBarOpen <= Highest(H,n1) and entry < 거래횟수 Then Buy("b1",AtStop,Highest(H,n1)+PriceScale*1); if MarketPosition >= 0 and NextBarOpen >= Lowest(L,N1) and entry < 거래횟수 Then Sell("s1",AtStop,Lowest(L,N1)-PriceScale*1); if MarketPosition == 1 Then ExitLong("bx",AtStop,Lowest(L,n)[BarsSinceEntry]-PriceScale*1); if MarketPosition == -1 Then ExitShort("sx",AtStop,Highest(H,n)[BarsSinceEntry]+PriceScale*1); } SetStopProfittarget(PriceScale*익절틱수,PointStop); SetStopLoss(PriceScale*손절틱수,PointStop); 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); } }