커뮤니티

검토 부탁드립니다.

프로필 이미지
고박사122
2018-10-24 07:57:09
251
글번호 122972
답변완료

첨부 이미지

안녕하세요. 작성해 주신 수식을 적용해 본결과 6틱, 12틱, 18틱 순차적으로 익절되어야 하지만 두개의 수량이 6틱에서 청산되고 나머지 1개의 물량이 18틱에서 청산되거나 또는 분할청산 되지 않고 한번에 청산되고 있습니다. 혹시 당일누적손실틱수에 적용되어 이러한 현상이 발생되는 것은 아닌지요? 오류를 바로잡아 주셨으면 합니다. input : 거래시간 (1), 시작시간 (160000), 끝시간 (045000),익절틱수1(6),익절틱수2(12),익절틱수3(18),손절틱수 (10); Input : 전환선기간 (5), 기준선기간1(26), 기준선기간2(1), 선행스팬2기간(52), short(12), long(26), sig(9),BBP(120), 당일누적손실틱수 (100); Var : MACDv(0), MACDsig(0),macdosc(0), Condition3(false); var : 전환선 (0), 기준선1(0), 기준선2(0), 후행스팬(0), 선행스팬1(0), 선행스팬2(0), Xcond(false),N1(0),daypl(0),당일누적손실 (0); var1 = MACD(short, long); var2 = ema(MACDv,sig); var3 = ma(C,BBP); 전환선 = (Highest(High, 전환선기간 ) + Lowest(Low, 전환선기간 )) / 2; 기준선1 = (Highest(High, 기준선기간1 ) + Lowest(Low, 기준선기간1 )) / 2; 기준선2 = (Highest(High, 기준선기간2 ) + Lowest(Low, 기준선기간2 )) / 2; 선행스팬1 = (전환선 [25] + 기준선2 [25]) / 2 ; 선행스팬2 = (Highest(High, 선행스팬2기간 )[25] + Lowest(Low, 선행스팬2기간 )[25]) / 2; if 거래시간 == 1 then condition3 = (stime>=시작시간 or stime<=끝시간); Else if 거래시간 == 2 then condition3 = (stime>=시작시간 and stime<=끝시간); Else condition3 = true; if 거래시간 == 1 or 거래시간 == 2 then { if (sdate != sdate[1] and stime >= 시작시간) or (sdate == sdate[1] and stime >= 시작시간 and stime[1] < 시작시간) Then { Xcond = false; N1 = NetProfit; } } else { if Bdate != Bdate[1] Then { Xcond = false; N1 = NetProfit; } } 당일누적손실 = PriceScale*당일누적손실틱수; daypl = NetProfit-N1; if TotalTrades > TotalTrades[1] and (IsExitName("dbl",1) == true or IsExitName("dsl",1) == true) then Xcond = true; # 매수/매도청산 if MarketPosition == 0 and TotalTrades == TotalTrades[3] and Condition3 == true and var3 > var3[1] and var1 > var2 and 전환선 > 기준선1 and crossup(C,전환선 ) and C > O Then { Buy("b",OnClose,def,3); } # 매도/매수청산 if MarketPosition == 0 and TotalTrades == TotalTrades[3] and Condition3 == true and var3 < var3[1] and var1 < var2 and 전환선 < 기준선1 and CrossDown(C,전환선 ) and C < O Then { Sell("s",OnClose,def,3); } if MarketPosition == 1 Then{ ExitLong("bp1",atlimit,EntryPrice+PriceScale*익절틱수1,"",1,1); ExitLong("bp2",atlimit,EntryPrice+PriceScale*익절틱수2,"",1,1); ExitLong("bp3",atlimit,EntryPrice+PriceScale*익절틱수3); } if MarketPosition == -1 Then{ ExitShort("sp1",atlimit,EntryPrice-PriceScale*익절틱수1,"",1,1); ExitShort("sp2",atlimit,EntryPrice-PriceScale*익절틱수2,"",1,1); ExitShort("sp3",atlimit,EntryPrice-PriceScale*익절틱수3); } SetStopLoss(PriceScale*손절틱수,PointStop); if stime == 끝시간 or (stime > 끝시간 and stime[1] < 끝시간 ) Then{ if MarketPosition == 1 Then ExitLong(); if MarketPosition == -1 Then ExitShort(); } if MarketPosition == 1 then{ ExitLong("dbl",AtStop,EntryPrice-((당일누적손실+daypl)/CurrentContracts)); } if MarketPosition == -1 then{ ExitShort("dsl",AtStop,EntryPrice+((당일누적손실+daypl)/CurrentContracts)); }
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2018-10-24 14:41:03

안녕하세요 예스스탁입니다. 각 청산은 서로의 신호발생에 관계가 없습니다. 다만 현재 진입이 onclose타입이고 익절청산이 매수포지션확인후 다음봉 부터 발생하게 되어 있어 진입신호봉 다음봉에서는 발생하지 않고 그 다음봉부터 발생하는데 시가가 지정한 익절청산틱수들보다 위에 발생하면 모두 한번에 청산이 됩니다. 최대한 진입다음봉 부터 발생하게 수정해 드립니다. input : 거래시간 (1), 시작시간 (160000), 끝시간 (045000),익절틱수1(6),익절틱수2(12),익절틱수3(18),손절틱수 (10); Input : 전환선기간 (5), 기준선기간1(26), 기준선기간2(1), 선행스팬2기간(52), short(12), long(26), sig(9),BBP(120), 당일누적손실틱수 (100); Var : MACDv(0), MACDsig(0),macdosc(0), Condition3(false); var : 전환선 (0), 기준선1(0), 기준선2(0), 후행스팬(0), 선행스팬1(0), 선행스팬2(0), Xcond(false),N1(0),daypl(0),당일누적손실 (0); var1 = MACD(short, long); var2 = ema(MACDv,sig); var3 = ma(C,BBP); 전환선 = (Highest(High, 전환선기간 ) + Lowest(Low, 전환선기간 )) / 2; 기준선1 = (Highest(High, 기준선기간1 ) + Lowest(Low, 기준선기간1 )) / 2; 기준선2 = (Highest(High, 기준선기간2 ) + Lowest(Low, 기준선기간2 )) / 2; 선행스팬1 = (전환선 [25] + 기준선2 [25]) / 2 ; 선행스팬2 = (Highest(High, 선행스팬2기간 )[25] + Lowest(Low, 선행스팬2기간 )[25]) / 2; if 거래시간 == 1 then condition3 = (stime>=시작시간 or stime<=끝시간); Else if 거래시간 == 2 then condition3 = (stime>=시작시간 and stime<=끝시간); Else condition3 = true; if 거래시간 == 1 or 거래시간 == 2 then { if (sdate != sdate[1] and stime >= 시작시간) or (sdate == sdate[1] and stime >= 시작시간 and stime[1] < 시작시간) Then { Xcond = false; N1 = NetProfit; } } else { if Bdate != Bdate[1] Then { Xcond = false; N1 = NetProfit; } } 당일누적손실 = PriceScale*당일누적손실틱수; daypl = NetProfit-N1; if TotalTrades > TotalTrades[1] and (IsExitName("dbl",1) == true or IsExitName("dsl",1) == true) then Xcond = true; # 매수/매도청산 if MarketPosition == 0 and TotalTrades == TotalTrades[3] and Condition3 == true and var3 > var3[1] and var1 > var2 and 전환선 > 기준선1 and crossup(C,전환선 ) and C > O Then { Buy("b",OnClose,def,3); ExitLong("bp1.",atlimit,C+PriceScale*익절틱수1,"",1,1); ExitLong("bp2.",atlimit,C+PriceScale*익절틱수2,"",1,1); ExitLong("bp3.",atlimit,C+PriceScale*익절틱수3); } # 매도/매수청산 if MarketPosition == 0 and TotalTrades == TotalTrades[3] and Condition3 == true and var3 < var3[1] and var1 < var2 and 전환선 < 기준선1 and CrossDown(C,전환선 ) and C < O Then { Sell("s",OnClose,def,3); ExitShort("sp1.",atlimit,C-PriceScale*익절틱수1,"",1,1); ExitShort("sp2.",atlimit,C-PriceScale*익절틱수2,"",1,1); ExitShort("sp3.",atlimit,C-PriceScale*익절틱수3); } if MarketPosition == 1 Then{ if highest(H,BarsSinceEntry) < EntryPrice+PriceScale*익절틱수1 then ExitLong("bp1",atlimit,EntryPrice+PriceScale*익절틱수1,"",1,1); if highest(H,BarsSinceEntry) < EntryPrice+PriceScale*익절틱수2 then ExitLong("bp2",atlimit,EntryPrice+PriceScale*익절틱수2,"",1,1); if highest(H,BarsSinceEntry) < EntryPrice+PriceScale*익절틱수3 then ExitLong("bp3",atlimit,EntryPrice+PriceScale*익절틱수3); } if MarketPosition == -1 Then{ if lowest(L,BarsSinceEntry) > EntryPrice-PriceScale*익절틱수1 Then ExitShort("sp1",atlimit,EntryPrice-PriceScale*익절틱수1,"",1,1); if lowest(L,BarsSinceEntry) > EntryPrice-PriceScale*익절틱수2 Then ExitShort("sp2",atlimit,EntryPrice-PriceScale*익절틱수2,"",1,1); if lowest(L,BarsSinceEntry) > EntryPrice-PriceScale*익절틱수3 Then ExitShort("sp3",atlimit,EntryPrice-PriceScale*익절틱수3); } SetStopLoss(PriceScale*손절틱수,PointStop); if stime == 끝시간 or (stime > 끝시간 and stime[1] < 끝시간 ) Then{ if MarketPosition == 1 Then ExitLong(); if MarketPosition == -1 Then ExitShort(); } if MarketPosition == 1 then { ExitLong("dbl",AtStop,EntryPrice-((당일누적손실+daypl)/CurrentContracts)); } if MarketPosition == -1 then { ExitShort("dsl",AtStop,EntryPrice+((당일누적손실+daypl)/CurrentContracts)); } 즐거운 하루되세요 > 고박사122 님이 쓴 글입니다. > 제목 : 검토 부탁드립니다. > 안녕하세요. 작성해 주신 수식을 적용해 본결과 6틱, 12틱, 18틱 순차적으로 익절되어야 하지만 두개의 수량이 6틱에서 청산되고 나머지 1개의 물량이 18틱에서 청산되거나 또는 분할청산 되지 않고 한번에 청산되고 있습니다. 혹시 당일누적손실틱수에 적용되어 이러한 현상이 발생되는 것은 아닌지요? 오류를 바로잡아 주셨으면 합니다. input : 거래시간 (1), 시작시간 (160000), 끝시간 (045000),익절틱수1(6),익절틱수2(12),익절틱수3(18),손절틱수 (10); Input : 전환선기간 (5), 기준선기간1(26), 기준선기간2(1), 선행스팬2기간(52), short(12), long(26), sig(9),BBP(120), 당일누적손실틱수 (100); Var : MACDv(0), MACDsig(0),macdosc(0), Condition3(false); var : 전환선 (0), 기준선1(0), 기준선2(0), 후행스팬(0), 선행스팬1(0), 선행스팬2(0), Xcond(false),N1(0),daypl(0),당일누적손실 (0); var1 = MACD(short, long); var2 = ema(MACDv,sig); var3 = ma(C,BBP); 전환선 = (Highest(High, 전환선기간 ) + Lowest(Low, 전환선기간 )) / 2; 기준선1 = (Highest(High, 기준선기간1 ) + Lowest(Low, 기준선기간1 )) / 2; 기준선2 = (Highest(High, 기준선기간2 ) + Lowest(Low, 기준선기간2 )) / 2; 선행스팬1 = (전환선 [25] + 기준선2 [25]) / 2 ; 선행스팬2 = (Highest(High, 선행스팬2기간 )[25] + Lowest(Low, 선행스팬2기간 )[25]) / 2; if 거래시간 == 1 then condition3 = (stime>=시작시간 or stime<=끝시간); Else if 거래시간 == 2 then condition3 = (stime>=시작시간 and stime<=끝시간); Else condition3 = true; if 거래시간 == 1 or 거래시간 == 2 then { if (sdate != sdate[1] and stime >= 시작시간) or (sdate == sdate[1] and stime >= 시작시간 and stime[1] < 시작시간) Then { Xcond = false; N1 = NetProfit; } } else { if Bdate != Bdate[1] Then { Xcond = false; N1 = NetProfit; } } 당일누적손실 = PriceScale*당일누적손실틱수; daypl = NetProfit-N1; if TotalTrades > TotalTrades[1] and (IsExitName("dbl",1) == true or IsExitName("dsl",1) == true) then Xcond = true; # 매수/매도청산 if MarketPosition == 0 and TotalTrades == TotalTrades[3] and Condition3 == true and var3 > var3[1] and var1 > var2 and 전환선 > 기준선1 and crossup(C,전환선 ) and C > O Then { Buy("b",OnClose,def,3); } # 매도/매수청산 if MarketPosition == 0 and TotalTrades == TotalTrades[3] and Condition3 == true and var3 < var3[1] and var1 < var2 and 전환선 < 기준선1 and CrossDown(C,전환선 ) and C < O Then { Sell("s",OnClose,def,3); } if MarketPosition == 1 Then{ ExitLong("bp1",atlimit,EntryPrice+PriceScale*익절틱수1,"",1,1); ExitLong("bp2",atlimit,EntryPrice+PriceScale*익절틱수2,"",1,1); ExitLong("bp3",atlimit,EntryPrice+PriceScale*익절틱수3); } if MarketPosition == -1 Then{ ExitShort("sp1",atlimit,EntryPrice-PriceScale*익절틱수1,"",1,1); ExitShort("sp2",atlimit,EntryPrice-PriceScale*익절틱수2,"",1,1); ExitShort("sp3",atlimit,EntryPrice-PriceScale*익절틱수3); } SetStopLoss(PriceScale*손절틱수,PointStop); if stime == 끝시간 or (stime > 끝시간 and stime[1] < 끝시간 ) Then{ if MarketPosition == 1 Then ExitLong(); if MarketPosition == -1 Then ExitShort(); } if MarketPosition == 1 then{ ExitLong("dbl",AtStop,EntryPrice-((당일누적손실+daypl)/CurrentContracts)); } if MarketPosition == -1 then{ ExitShort("dsl",AtStop,EntryPrice+((당일누적손실+daypl)/CurrentContracts)); }