커뮤니티

1차 거래 (익절시 2차 거래 허용)

프로필 이미지
목마와숙녀
2026-07-01 20:15:13
101
글번호 232642
답변완료

아래수식은

데이트레이딩용이며

하루 맥스 2회까지 거래하는 수식입니다.


요청사항

거래는 기본으로 1차만 하되,

1차 진입이  익절 _ SetStopProfittarget(gl1,PointStop) 로 청산되었을 경우에만

2차 거래를 허용하고 싶습니다.

즉, 기본 1차 거래(익절시 2차 거래 허용)


아래 수식에 반영하여 주십시요.


항상 고맙습니다.


*********************************************************************************************


input : 진입시간(090000),진입제한시간(100000);

input : 거래횟수(2);

input : 수량1(1),b1(20),진입눌림1(0),진입돌파1(0);

input : 수량2(1),b2(40),진입눌림2(0),진입돌파2(0);

input : ls1(1000),tr1(2000),gl1(4000);

input : ls2(1500),tr2(3000),gl2(6000);

input : eod(151500);


var : T1(0),entry(0),LL(0),EH(0),E1(0),H1(0),i1(0),S1(0),L1(0),V1(0);

var : Tcond(false);


if (sdate != sdate[1] and stime >= 진입시간) or

       (sdate == sdate[1] and stime >= 진입시간 and stime[1] < 진입시간) Then

       Tcond = true;

   

if (sdate != sdate[1] and stime >= 진입제한시간) or

       (sdate == sdate[1] and stime >= 진입제한시간 and stime[1] < 진입제한시간) Then

       Tcond = false;

   

if (sdate != sdate[1] and stime >= 진입시간) or

       (sdate == sdate[1] and stime >= 진입시간 and stime[1] < 진입시간) Then{

       T1 = TotalTrades;

       E1 = 0;

       LL = L;

}


if stime >= 진입시간 then{

       if L < LL Then

             LL = L;

       

       if MarketPosition == 0 Then

             entry = TotalTrades-T1;

       Else

             entry = (TotalTrades-T1)+1;

          

       

       if MarketPosition == 0 and entry == 0 Then{

             if E1 == 0 and C >= LL+B1 Then{

                   E1 = 1;

                   H1 = H;

                   i1 = index;

                   V1 = LL; //시작점 종가

            }

             if E1 == 1 and index > i1 then{

                   if H > H1 Then

                         H1 = H;

                   #저가가 시작봉종가보다 클때만 눌림체크

                  if L >= V1 and L <= H1-진입눌림1 Then{

                         E1 = 2;

                         i1 = index;

                         S1 = H1;

                   }

             }

             //시작점 종가보다 낮은 가격이 발생하면 초기화

            if E1 >= 1 and L < V1 Then{

                   E1 = 0;

                   LL = L;

             }

             if E1 == 2 and index > i1 and C >= S1+진입돌파1 and Tcond == true  Then{

                   Buy("b1",OnClose,Def,수량1);

             }

       }

       


           

        if TotalTrades > TotalTrades[1] Then{

             E1 = 0;

             LL = L;

       }

       if L < LL Then

             LL = L;

                     

       if MarketPosition == 0 and entry >= 1 and entry < 거래횟수 Then{

             if E1 == 0 and C >= LL+B2 Then{

                   E1 = 1;

                   H1 = H;

                   i1 = index;

                   V1 = LL; //시작점 종가

            }

             if E1 == 1 and index > i1 then{

                   if H > H1 Then

                         H1 = H;

                   

                   #저가가 시작봉종가보다 클때만 눌림체크

                  if L >= V1 and L <= H1-진입눌림2 Then{

                         E1 = 2;

                         i1 = index;

                         S1 = H1;

                   }

             }

             //시작점 종가보다 낮은 가격이 발생하면 초기화

            if E1 >= 1 and L < V1 Then{

                   E1 = 0;

                   LL = L;

             }

                

             if E1 == 2 and index > i1 and C >= S1+진입돌파2 and Tcond == true Then{

    Buy("b2",OnClose,Def,수량2);

             }

       }



if MarketPosition== 1 Then

{

      if IsEntryName("b1") == true Then

      {

            SetStopLoss(ls1,PointStop);

            SetStopTrailing(tr1,0,PointStop,1);

            SetStopProfittarget(gl1,PointStop);


      }

      Else if IsEntryName("b2") == true Then

      {

            SetStopLoss(ls2,PointStop);

            SetStopTrailing(tr2,0,PointStop,1);

            SetStopProfittarget(gl2,PointStop);



      }

      Else

      {

            SetStopLoss(0);

            SetStopTrailing(0,0);

            SetStopProfittarget(0);

           

      }

}


SetStopEndofday(eod);


}

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

예스스탁 예스스탁 답변

2026-07-02 13:54:28

안녕하세요 예스스탁입니다. input : 진입시간(090000),진입제한시간(100000); input : 거래횟수(2); input : 수량1(1),b1(20),진입눌림1(0),진입돌파1(0); input : 수량2(1),b2(40),진입눌림2(0),진입돌파2(0); input : ls1(1000),tr1(2000),gl1(4000); input : ls2(1500),tr2(3000),gl2(6000); input : eod(151500); var : T1(0),entry(0),LL(0),EH(0),E1(0),H1(0),i1(0),S1(0),L1(0),V1(0); var : Tcond(false); if (sdate != sdate[1] and stime >= 진입시간) or (sdate == sdate[1] and stime >= 진입시간 and stime[1] < 진입시간) Then Tcond = true; if (sdate != sdate[1] and stime >= 진입제한시간) or (sdate == sdate[1] and stime >= 진입제한시간 and stime[1] < 진입제한시간) Then Tcond = false; if (sdate != sdate[1] and stime >= 진입시간) or (sdate == sdate[1] and stime >= 진입시간 and stime[1] < 진입시간) Then{ T1 = TotalTrades; E1 = 0; LL = L; } if stime >= 진입시간 then{ if L < LL Then LL = L; if MarketPosition == 0 Then entry = TotalTrades-T1; Else entry = (TotalTrades-T1)+1; if MarketPosition == 0 and entry == 0 Then{ if E1 == 0 and C >= LL+B1 Then{ E1 = 1; H1 = H; i1 = index; V1 = LL; //시작점 종가 } if E1 == 1 and index > i1 then{ if H > H1 Then H1 = H; #저가가 시작봉종가보다 클때만 눌림체크 if L >= V1 and L <= H1-진입눌림1 Then{ E1 = 2; i1 = index; S1 = H1; } } //시작점 종가보다 낮은 가격이 발생하면 초기화 if E1 >= 1 and L < V1 Then{ E1 = 0; LL = L; } if E1 == 2 and index > i1 and C >= S1+진입돌파1 and Tcond == true Then{ Buy("b1",OnClose,Def,수량1); } } if TotalTrades > TotalTrades[1] Then{ E1 = 0; LL = L; } if L < LL Then LL = L; if MarketPosition == 0 and entry >= 1 and entry < 거래횟수 Then{ if E1 == 0 and C >= LL+B2 Then{ E1 = 1; H1 = H; i1 = index; V1 = LL; //시작점 종가 } if E1 == 1 and index > i1 then{ if H > H1 Then H1 = H; #저가가 시작봉종가보다 클때만 눌림체크 if L >= V1 and L <= H1-진입눌림2 Then{ E1 = 2; i1 = index; S1 = H1; } } //시작점 종가보다 낮은 가격이 발생하면 초기화 if E1 >= 1 and L < V1 Then{ E1 = 0; LL = L; } if E1 == 2 and index > i1 and C >= S1+진입돌파2 and Tcond == true and IsExitName("StopProfitTarget",1) == true Then{ Buy("b2",OnClose,Def,수량2); } } if MarketPosition== 1 Then { if IsEntryName("b1") == true Then { SetStopLoss(ls1,PointStop); SetStopTrailing(tr1,0,PointStop,1); SetStopProfittarget(gl1,PointStop); } Else if IsEntryName("b2") == true Then { SetStopLoss(ls2,PointStop); SetStopTrailing(tr2,0,PointStop,1); SetStopProfittarget(gl2,PointStop); } Else { SetStopLoss(0); SetStopTrailing(0,0); SetStopProfittarget(0); } } SetStopEndofday(eod); } 즐거운 하루되세요