커뮤니티

수식문의드립니다

프로필 이미지
jshwang2
2022-02-09 01:54:27
1160
글번호 156127
답변완료
안녕하세요 수식 질문 하나 드립니다! 매수(매도) 한쪽 방향으로 3회 진입하면 추가진입이 안되도록 만들고 싶습니다 생각엔 매수에 Hcount, 매도에 Lcount라는 변수를 정의하고 청산이 이뤄질때마다 Hcount = Hcount +1이 되도록 해 Hcount가 3이 넘으면 진입이 안되도록 하면 될것같은데... 아래와 같은 상황에서 청산시 어떻게 count 해야될지를 모르겠습니다... input : TT(55700), TD(20220205), N(5) ; var : HB(14710), LB(14680), e60(0), Hcount(0), Lcount(0) ; e60 = Ema(C,60); if sDate >= TD and sTime >= TT Then Condition1 = true; if Condition1 == true Then { if Hcount < 3 then Buy("b",AtStop,HB,2) ; if Lcount < 3 then Sell("s",AtStop,LB,2) ; if marketposition > 0 Then { if e60 < HB Then ExitLong("exitL1",AtStop,HB-N); if e60 >= HB && CrossDown(close, e60) Then ExitLong("exitL2") ; HB = Highest(H, BarsSinceEntry) ; } if marketposition < 0 Then { if e60 > LB Then ExitShort("exitS1",AtStop,LB+N); if e60 <= LB && CrossUp(close, e60) Then ExitShort("exitS2"); LB = Lowest(L, BarsSinceEntry); } } ------------------------------- if e60 >= HB && CrossDown(close, e60) Then ExitLong("exitL2") ; 이 상황에선 그냥 조건 만족할때 Hcount = Hcount + 1을 추가하면 될것 같은데 if e60 < HB Then ExitLong("exitL1",AtStop,HB-N); 여기선 방법이 안떠오르네요 혹시 청산되는 상황 자체를 감지해 count 할 수 있는 방법이나 해결할 다른 방법이 있는지 조언 부탁드리겠습니다 감사합니다
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2022-02-09 10:56:18

안녕하세요 예스스탁입니다. 아래와 같이 매수진입과 매도진입갯수 카운트해서 사용하시면 됩니다. input : TT(55700), TD(20220205), N(5) ; var : HB(14710), LB(14680), e60(0), Hcount(0), Lcount(0),B(0),S(0),cnt(0),T1(0) ; e60 = Ema(C,60); if Condition1 == False and sDate >= TD and sTime >= TT Then { Condition1 = true; Hcount = 0; Lcount = 0; T1 = TotalTrades; } if Condition1 == true Then { B = 0; S = 0; if TotalTrades-T1 > 0 Then { For cnt = 1 to TotalTrades-T1 { if MarketPosition(cnt) == 1 Then { B = B+1; } if MarketPosition(cnt) == -1 Then { S = S+1; } } } Hcount = B + IFf(MarketPosition == 1,1,0); Lcount = S + IFf(MarketPosition == -1,1,0); if Hcount < 3 then Buy("b",AtStop,HB,2) ; if Lcount < 3 then Sell("s",AtStop,LB,2) ; if marketposition > 0 Then { if e60 < HB Then ExitLong("exitL1",AtStop,HB-N); if e60 >= HB && CrossDown(close, e60) Then ExitLong("exitL2") ; HB = Highest(H, BarsSinceEntry) ; } if marketposition < 0 Then { if e60 > LB Then ExitShort("exitS1",AtStop,LB+N); if e60 <= LB && CrossUp(close, e60) Then ExitShort("exitS2"); LB = Lowest(L, BarsSinceEntry); } } 즐거운 하루되세요 > jshwang2 님이 쓴 글입니다. > 제목 : 수식문의드립니다 > 안녕하세요 수식 질문 하나 드립니다! 매수(매도) 한쪽 방향으로 3회 진입하면 추가진입이 안되도록 만들고 싶습니다 생각엔 매수에 Hcount, 매도에 Lcount라는 변수를 정의하고 청산이 이뤄질때마다 Hcount = Hcount +1이 되도록 해 Hcount가 3이 넘으면 진입이 안되도록 하면 될것같은데... 아래와 같은 상황에서 청산시 어떻게 count 해야될지를 모르겠습니다... input : TT(55700), TD(20220205), N(5) ; var : HB(14710), LB(14680), e60(0), Hcount(0), Lcount(0) ; e60 = Ema(C,60); if sDate >= TD and sTime >= TT Then Condition1 = true; if Condition1 == true Then { if Hcount < 3 then Buy("b",AtStop,HB,2) ; if Lcount < 3 then Sell("s",AtStop,LB,2) ; if marketposition > 0 Then { if e60 < HB Then ExitLong("exitL1",AtStop,HB-N); if e60 >= HB && CrossDown(close, e60) Then ExitLong("exitL2") ; HB = Highest(H, BarsSinceEntry) ; } if marketposition < 0 Then { if e60 > LB Then ExitShort("exitS1",AtStop,LB+N); if e60 <= LB && CrossUp(close, e60) Then ExitShort("exitS2"); LB = Lowest(L, BarsSinceEntry); } } ------------------------------- if e60 >= HB && CrossDown(close, e60) Then ExitLong("exitL2") ; 이 상황에선 그냥 조건 만족할때 Hcount = Hcount + 1을 추가하면 될것 같은데 if e60 < HB Then ExitLong("exitL1",AtStop,HB-N); 여기선 방법이 안떠오르네요 혹시 청산되는 상황 자체를 감지해 count 할 수 있는 방법이나 해결할 다른 방법이 있는지 조언 부탁드리겠습니다 감사합니다