커뮤니티

데이트레이딩 수식을 오버나잇 수식으로 변경(예스스팟 신호발생용)

프로필 이미지
목마와숙녀
2026-05-03 18:17:43
125
글번호 231865
답변완료

아래수식은 주간용 전략실행차트 수식입니다.

end of day는 151500 이며 데이트레이딩용 수식입니다.

- 진입프로세스

b1(진입명)이 첫번째로 한번만 진입하고, b2(진입명)가 두번째 부터 반복하여 진입합니다.

    ex) 다섯번 거래한다면  b1,b2,b2,b2,b2


아래 데이트레이딩 수식을 오버나잇으로 변경하고 복합용 전략실행차트에서 사용코자 합니다.

하지만, 위클리옵션 만기일에는 오버나잇을 멈추고 장종료 5분전인 151500에 청산해야 합니다.

이것을 가능하게 할 수식으로 수정하여 주십시요.


수식은 2개로 분류하여  사용할 예정입니다.

        - 월요일 만기용

        - 목요일 만기용

 

변경된 수식에서도 진입프로세스는 주간 전략수식과 동일합니다.

  ex) 다섯번 거래한다면  b1,b2,b2,b2,b2

변경된 수식에서 진입제한시간,거래횟수,누적패수 내용은 삭제하여 주십시요.


요청수식1


  - 월요일 만기용 (복합 전략실행차트 )

      금요일 084500부터 진입 허용,금요일과 주말 오버나잇

      다음주 월요일 151500에 종료(위클리옵션 월요일 만기)


요청수식2


- 목요일 만기용 (복합 전략실행차트 )

     화요일 084500부터 진입 허용,화요일과 수요일 오버나잇

     목요일 151500에 종료(위클리옵션 목요일 만기)  

      

항상 고맙습니다.



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



// ==================================================

// [입력 변수 설정]

// ==================================================

input : 최대(999999),최소(700);

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

input : 거래횟수(5),누적패수(5);

input : b1(2.25),진입눌림1(0.25),진입돌파1(0.25);

input : 경과봉(0);

input : b2(3.50),진입눌림2(0.50),진입돌파2(0.50);

input : als(4.5),atr1(0),atr2(5.5);

input : bls(5.5),btr1(0),btr2(6.5);

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);

var : loss(0);


// ==================================================

// [일자 변경 시 손실 카운트 초기화]

// ==================================================

if bdate != bdate[1] Then

    loss = 0;


// ==================================================

// [직전 트레이드 손실 시 누적 패수 증가]

// ==================================================

if TotalTrades > TotalTrades[1] and PositionProfit(1) < 0 Then

    loss = loss+1;


// ==================================================

// [진입 가능 시간 조건 ON]

// ==================================================

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

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

    Tcond = true;


// ==================================================

// [진입 제한 시간 이후 조건 OFF]

// ==================================================

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;


    // ==================================================

    // [1차 진입 로직]

// ==================================================

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


        // --- 1차 진입 시작 조건 ---

        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;

        }


        // --- 1차 매수 진입 ---

        if loss < 누적패수 and E1 == 2 and index > i1 and

           C >= S1+진입돌파1 and Tcond and 최대 >= C and C >= 최소 Then{

            buy("b1");

        }

    }


    // ==================================================

    // [체결 발생 시 패턴 리셋]

// ==================================================

    if TotalTrades > TotalTrades[1] Then{

        E1 = 0;

        LL = L;

    }


    // ----------------------------------------------

    // [최저가 재갱신 보호]

// ----------------------------------------------

    if L < LL Then

        LL = L;


    // ==================================================

    // [2차 진입 로직]

// ==================================================

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


        // --- 2차 진입 시작 조건 ---

        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;

        }


        // --- 2차 매수 진입 ---

        if dayindex>=경과봉 and loss < 누적패수 and E1 == 2 and index > i1 and

           C >= S1+진입돌파2 and Tcond and 최대 >= C and C >= 최소 Then{

            buy("b2");

        }

    }

}



if MarketPosition== 1 Then

{

      if IsEntryName("b1") == true Then

      {

            SetStopLoss(als,PointStop);

            SetStopTrailing(atr2,atr1,PointStop,1);


      }

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

      {

            SetStopLoss(bls,PointStop);

            SetStopTrailing(btr2,btr1,PointStop,1);


      }

      Else

      {

            SetStopLoss(0);

SetStopTrailing(0,0);

           

      }

}


SetStopEndofday(eod);



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

예스스탁 예스스탁 답변

2026-05-06 13:21:44

안녕하세요 예스스탁입니다. 1 // ================================================== // [입력 변수 설정] // ================================================== input : 최대(999999),최소(700); input : 진입시간(084500); input : b1(2.25),진입눌림1(0.25),진입돌파1(0.25); input : 경과봉(0); input : b2(3.50),진입눌림2(0.50),진입돌파2(0.50); input : als(4.5),atr1(0),atr2(5.5); input : bls(5.5),btr1(0),btr2(6.5); 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); var : loss(0); // ================================================== // [일자 변경 시 손실 카운트 초기화] // ================================================== if bdate != bdate[1] Then loss = 0; // ================================================== // [직전 트레이드 손실 시 누적 패수 증가] // ================================================== if TotalTrades > TotalTrades[1] and PositionProfit(1) < 0 Then loss = loss+1; // ================================================== // [진입 가능 시간 조건 ON] - 금요일 08시45분 // ================================================== if DayOfWeek(sDate) == 5 and ((sdate != sdate[1] and stime >= 진입시간) or (sdate == sdate[1] and stime >= 진입시간 and stime[1] < 진입시간)) Then { Tcond = true; } // ================================================== // [진입 가능 시간 조건 OFF] - 월요일 15시15분 // ================================================== if DayOfWeek(sDate) == 1 and ((sdate != sdate[1] and stime >= 151500) or (sdate == sdate[1] and stime >= 151500 and stime[1] < 151500)) 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 Tcond == true then { // ---------------------------------------------- // [일중 최저가 갱신] // ---------------------------------------------- if L < LL Then LL = L; // ---------------------------------------------- // [진입 차수 계산] // ---------------------------------------------- if MarketPosition == 0 Then entry = TotalTrades-T1; Else entry = (TotalTrades-T1)+1; // ================================================== // [1차 진입 로직] // ================================================== if MarketPosition == 0 and entry == 0 Then { // --- 1차 진입 시작 조건 --- 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; } // --- 1차 매수 진입 --- if E1 == 2 and index > i1 and C >= S1+진입돌파1 and Tcond and 최대 >= C and C >= 최소 Then { buy("b1"); } } // ================================================== // [체결 발생 시 패턴 리셋] // ================================================== if TotalTrades > TotalTrades[1] Then { E1 = 0; LL = L; } // ---------------------------------------------- // [최저가 재갱신 보호] // ---------------------------------------------- if L < LL Then LL = L; // ================================================== // [2차 진입 로직] // ================================================== if MarketPosition == 0 and entry >= 1 Then { // --- 2차 진입 시작 조건 --- 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; } // --- 2차 매수 진입 --- if dayindex>=경과봉 and E1 == 2 and index > i1 and C >= S1+진입돌파2 and Tcond and 최대 >= C and C >= 최소 Then { buy("b2"); } } } if MarketPosition== 1 Then { if IsEntryName("b1") == true Then { SetStopLoss(als,PointStop); SetStopTrailing(atr2,atr1,PointStop,1); } Else if IsEntryName("b2") == true Then { SetStopLoss(bls,PointStop); SetStopTrailing(btr2,btr1,PointStop,1); } Else { SetStopLoss(0); SetStopTrailing(0,0); } } if sDate != sDate[1] Then { if DayOfWeek(sDate) == 1 Then SetStopEndofday(eod); else SetStopEndofday(0); } 2 // ================================================== // [입력 변수 설정] // ================================================== input : 최대(999999),최소(700); input : 진입시간(084500); input : b1(2.25),진입눌림1(0.25),진입돌파1(0.25); input : 경과봉(0); input : b2(3.50),진입눌림2(0.50),진입돌파2(0.50); input : als(4.5),atr1(0),atr2(5.5); input : bls(5.5),btr1(0),btr2(6.5); 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); var : loss(0); // ================================================== // [일자 변경 시 손실 카운트 초기화] // ================================================== if bdate != bdate[1] Then loss = 0; // ================================================== // [직전 트레이드 손실 시 누적 패수 증가] // ================================================== if TotalTrades > TotalTrades[1] and PositionProfit(1) < 0 Then loss = loss+1; // ================================================== // [진입 가능 시간 조건 ON] - 화요일 08시45분 // ================================================== if DayOfWeek(sDate) == 2 and ((sdate != sdate[1] and stime >= 진입시간) or (sdate == sdate[1] and stime >= 진입시간 and stime[1] < 진입시간)) Then { Tcond = true; } // ================================================== // [진입 가능 시간 조건 OFF] - 목요일 15시15분 // ================================================== if DayOfWeek(sDate) == 4 and ((sdate != sdate[1] and stime >= 151500) or (sdate == sdate[1] and stime >= 151500 and stime[1] < 151500)) 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 Tcond == true then { // ---------------------------------------------- // [일중 최저가 갱신] // ---------------------------------------------- if L < LL Then LL = L; // ---------------------------------------------- // [진입 차수 계산] // ---------------------------------------------- if MarketPosition == 0 Then entry = TotalTrades-T1; Else entry = (TotalTrades-T1)+1; // ================================================== // [1차 진입 로직] // ================================================== if MarketPosition == 0 and entry == 0 Then { // --- 1차 진입 시작 조건 --- 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; } // --- 1차 매수 진입 --- if E1 == 2 and index > i1 and C >= S1+진입돌파1 and Tcond and 최대 >= C and C >= 최소 Then { buy("b1"); } } // ================================================== // [체결 발생 시 패턴 리셋] // ================================================== if TotalTrades > TotalTrades[1] Then { E1 = 0; LL = L; } // ---------------------------------------------- // [최저가 재갱신 보호] // ---------------------------------------------- if L < LL Then LL = L; // ================================================== // [2차 진입 로직] // ================================================== if MarketPosition == 0 and entry >= 1 Then { // --- 2차 진입 시작 조건 --- 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; } // --- 2차 매수 진입 --- if dayindex>=경과봉 and E1 == 2 and index > i1 and C >= S1+진입돌파2 and Tcond and 최대 >= C and C >= 최소 Then { buy("b2"); } } } if MarketPosition== 1 Then { if IsEntryName("b1") == true Then { SetStopLoss(als,PointStop); SetStopTrailing(atr2,atr1,PointStop,1); } Else if IsEntryName("b2") == true Then { SetStopLoss(bls,PointStop); SetStopTrailing(btr2,btr1,PointStop,1); } Else { SetStopLoss(0); SetStopTrailing(0,0); } } if sDate != sDate[1] Then { if DayOfWeek(sDate) == 1 Then SetStopEndofday(eod); else SetStopEndofday(0); } 즐거운 하루되세요