커뮤니티

분할매도에서 재진입 하는 시스템 문의드립니다.

프로필 이미지
일목초인
2026-02-05 11:28:59
105
글번호 230346
답변완료

안녕하세요~ 분할 매도에서 매수 조건 충족시 재진입하는 식을 구현하고자 합니다.

다음과 같은 예제 부탁드립니다.


매수: 볼린저밴드 상단선 위


1차 매도: 최근 20일 최고가 대비 ATR x 1.5 만큼 하락시 보유량의 25% 매도

2차 매도: 최근 20일 최고가 대비 TR x 2.5 만큼 하락시 보유량의 50% 매도

3차 매도: 최근 20일 최고가 대비 ATR x 3.5 만큼 하락시 보유량의 100% 매도


1차나 2차 매도된 상태에서 다시 주가가 볼린저밴드 상단선 위를 만족하면 다시 매수해서 100% 상태로 변경


항상 감사합니다!


시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2026-02-05 15:20:45

안녕하세요 예스스탁입니다. 아래식 참고하시기 바랍니다. 추가진입하므로 피라미딩은 모든진입신호 허용으로 설정하시면 됩니다. input : Period(20); var : sumTR(0),TH(0),TL(0),cnt(0),ATRV(0),HH(0); var : bbup(0); HH = 0; sumTR = 0; for cnt = 1 to Period { if hh == 0 or (hh > 0 and DayHigh(cnt) > hh) Then hh = DayHigh(cnt); If DayClose(cnt+1) > DayHigh(cnt) then TH = DayClose(cnt+1); else TH = DayHigh(cnt); If DayClose(cnt+1) < daylow(cnt) then TL = DayClose(cnt+1); else TL = daylow(cnt); sumTR = sumTR + (TH-TL); } ATRV = sumTR/Period; bbup = BollBandUp(20,2); if MarketPosition == 0 and CrossUp(C,bbup) Then Buy(); if MarketPosition == 1 Then { if CurrentContracts > CurrentContracts[1] Then { Condition1 = false; Condition2 = False; Condition3 = False; } if CurrentContracts < CurrentContracts[1] then { if LatestExitName(0) == "bx1" Then Condition1 = true; if LatestExitName(0) == "bx2" Then Condition2 = true; if LatestExitName(0) == "bx3" Then Condition3 = true; } if Condition1 == false and L > hh-ATRV*1.5 Then ExitLong("bx1",AtStop,hh-ATRV*1.5,"",Floor(MaxContracts*0.25),1); if Condition2 == false and L > hh-ATRV*2.5 Then ExitLong("bx2",AtStop,hh-ATRV*2.5,"",Floor(MaxContracts*0.50),1); if Condition3 == false and L > hh-ATRV*3.5 Then ExitLong("bx3",AtStop,hh-ATRV*3.5); if CurrentContracts < MaxContracts and C > bbup Then Buy("rb",OnClose,Def,MaxContracts-CurrentContracts); } Else { Condition1 = False; Condition2 = False; Condition3 = False; } 즐거운 하루되세요