커뮤니티

수식문의드립니다

프로필 이미지
jshwang2
2022-08-28 22:39:27
1328
글번호 161794
답변완료

첨부 이미지

안녕하세요~ 아래와 같이 수식을 짰는데 테스트 중 원인을 알수없는 진입을 발견해 문의드립니다 ----------------------------------------------- input : HB(13163), LB(13128), TT1(120000), TT2(213200), TD(20220826), MDD(100000); var : Bsystem(False), Ssystem(False), Fsystem(true), unitP(0), condition1(true); // MACD 변수 input : 타주기분(5),short(12),long(26),sig(9); var : S1(0),D1(0),TM(0),EP1(0),EP2(0),EP3(0),MACDO(0); var : TF(0),xma1(0),xma2(0),idx(0),Prexma1(0),Prexma2(0),MACDV(0),MACDS(0),PreMACDS(0); unitP = floor(MDD/(2*ATR(14)*BigPointValue*1400)); if sDate >= TD && TT2 > sTime && sTime > TT1 Then condition11 = true; Else condition11 = False; if condition11 == true Then { MessageLog("rsi %.4f, ATR %.4f, unitP %.4f, MP %.4f, macdV %.4f", rsi(14), ATR(14), unitP, MarketPosition, MACDV); MessageLog("H %.4f, L %.4f, BS %4s, SS %4s, FS %4s", H, L, Bsystem, Ssystem, Fsystem); // 횡보구간 이탈 - 회귀 - 매수매도구간 진입 if H > HB + 15 Then Fsystem = False; if L < LB - 15 Then Fsystem = False; if HB > C && C > LB && condition1 == true Then Fsystem = true; if H > HB + 30 Then { Bsystem = true; condition1 = False; } if L < LB - 30 Then { Ssystem = true; condition1 = False; } // 진입 if Bsystem == true && RSI(14) <= 30 Then Buy("b1-1", OnClose, Def, unitP); if Ssystem == true && RSI(14) >= 70 Then Sell("s2-1", OnClose, Def, unitP); if Fsystem == true Then { if RSI(14) <= 30 Then Buy("b3-1", OnClose, Def, unitP); if RSI(14) >= 70 Then Sell("s3-1", OnClose, Def, unitP); } //청산 if marketposition == 1 then { ExitLong("xL1", AtLimit, EntryPrice + 2*ATr(14)); ExitLong("xL2", AtStop, EntryPrice - 2*ATr(14)); } if MarketPosition == -1 Then { ExitShort("xS1", AtLimit, EntryPrice - 2*ATr(14)); ExitShort("xS2", AtStop, EntryPrice + 2*ATr(14)); } } // 매수매도 off Ep1 = 2/(short+1); Ep2 = 2/(long+1); Ep3 = 2/(sig+1); if Bdate != Bdate[1] Then { S1 = TimeToMinutes(stime); D1 = sdate; } if D1 > 0 then { if sdate == D1 Then TM = TimeToMinutes(stime)-S1; Else TM = TimeToMinutes(stime)+1440-S1; TF = TM%타주기분; if Bdate != Bdate[1] or (Bdate == Bdate[1] and 타주기분 > 1 and TF < TF[1]) or (Bdate == Bdate[1] and 타주기분 > 1 and TM >= TM[1]+타주기분) or (Bdate == Bdate[1] and 타주기분 == 1 and TM > TM[1]) Then { idx = idx + 1; Prexma1 = xma1[1]; Prexma2 = xma2[1]; PreMACDS = MACDS[1]; } if idx <= 1 then { xma1 = C; xma2 = C; MACDV = xma1-xma2; MACDS = MACDV; MACDO = MACDV-MACDS; } else { xma1 = C * EP1 + Prexma1 * (1-EP1); xma2 = C * EP2 + Prexma2 * (1-EP2); MACDV = xma1-xma2; MACDS = MACDV * EP3 + PreMACDS * (1-EP3); MACDO = MACDV-MACDS; } if condition11 == True Then { if Ssystem == true && MACDV > 0 Then Ssystem = False; if Bsystem == true && MACDV < 0 Then Bsystem = false; } } ------------------------------ 제가 짠 수식에선 Bsystem, Ssystem, Fsystem 최소한 셋 중 하나는 true이어야만 진입이 발생할 수 있는데 첨부한 사진을 보면 21:31에 세 조건이 모두 false인데 매도진입이 이뤄졌습니다 =>로그 상의 BS, SS, FS 값이 모두 false인 상황 3개 조건에 한해서만 진입조건을 걸어뒀는데 왜 이런 진입이 일어났는지 아무리 봐도 모르겠어서 살펴봐주시면 감사하겠습니다 감사합니다
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2022-08-29 10:49:37

안녕하세요 예스스탁입니다. 수식은 위에서 아래방향으로 읽어 들어 갑니다. 메세지로그를 변수에 할당하기 전에 출력하게 하면 현재봉에 출력되는 메세지로그는 전봉값입니다. 아래와 같이 메세지로그의 위치를 변수에 값을 저장하는 내용 아래로 옮겨 현재봉에서 값을 계산해서 할당 후에 메세지로 출력되게 하셔야 합니다. if condition11 == true Then { // 횡보구간 이탈 - 회귀 - 매수매도구간 진입 if H > HB + 15 Then Fsystem = False; if L < LB - 15 Then Fsystem = False; if HB > C && C > LB && condition1 == true Then Fsystem = true; if H > HB + 30 Then { Bsystem = true; condition1 = False; } if L < LB - 30 Then { Ssystem = true; condition1 = False; } MessageLog("rsi %.4f, ATR %.4f, unitP %.4f, MP %.4f, macdV %.4f", rsi(14), ATR(14), unitP, MarketPosition, MACDV); MessageLog("H %.4f, L %.4f, BS %4s, SS %4s, FS %4s", H, L, Bsystem, Ssystem, Fsystem); // 진입 if Bsystem == true && RSI(14) <= 30 Then Buy("b1-1", OnClose, Def, unitP); if Ssystem == true && RSI(14) >= 70 Then Sell("s2-1", OnClose, Def, unitP); if Fsystem == true Then { if RSI(14) <= 30 Then Buy("b3-1", OnClose, Def, unitP); if RSI(14) >= 70 Then Sell("s3-1", OnClose, Def, unitP); } 즐거운 하루되세요 > jshwang2 님이 쓴 글입니다. > 제목 : 수식문의드립니다 > 안녕하세요~ 아래와 같이 수식을 짰는데 테스트 중 원인을 알수없는 진입을 발견해 문의드립니다 ----------------------------------------------- input : HB(13163), LB(13128), TT1(120000), TT2(213200), TD(20220826), MDD(100000); var : Bsystem(False), Ssystem(False), Fsystem(true), unitP(0), condition1(true); // MACD 변수 input : 타주기분(5),short(12),long(26),sig(9); var : S1(0),D1(0),TM(0),EP1(0),EP2(0),EP3(0),MACDO(0); var : TF(0),xma1(0),xma2(0),idx(0),Prexma1(0),Prexma2(0),MACDV(0),MACDS(0),PreMACDS(0); unitP = floor(MDD/(2*ATR(14)*BigPointValue*1400)); if sDate >= TD && TT2 > sTime && sTime > TT1 Then condition11 = true; Else condition11 = False; if condition11 == true Then { MessageLog("rsi %.4f, ATR %.4f, unitP %.4f, MP %.4f, macdV %.4f", rsi(14), ATR(14), unitP, MarketPosition, MACDV); MessageLog("H %.4f, L %.4f, BS %4s, SS %4s, FS %4s", H, L, Bsystem, Ssystem, Fsystem); // 횡보구간 이탈 - 회귀 - 매수매도구간 진입 if H > HB + 15 Then Fsystem = False; if L < LB - 15 Then Fsystem = False; if HB > C && C > LB && condition1 == true Then Fsystem = true; if H > HB + 30 Then { Bsystem = true; condition1 = False; } if L < LB - 30 Then { Ssystem = true; condition1 = False; } // 진입 if Bsystem == true && RSI(14) <= 30 Then Buy("b1-1", OnClose, Def, unitP); if Ssystem == true && RSI(14) >= 70 Then Sell("s2-1", OnClose, Def, unitP); if Fsystem == true Then { if RSI(14) <= 30 Then Buy("b3-1", OnClose, Def, unitP); if RSI(14) >= 70 Then Sell("s3-1", OnClose, Def, unitP); } //청산 if marketposition == 1 then { ExitLong("xL1", AtLimit, EntryPrice + 2*ATr(14)); ExitLong("xL2", AtStop, EntryPrice - 2*ATr(14)); } if MarketPosition == -1 Then { ExitShort("xS1", AtLimit, EntryPrice - 2*ATr(14)); ExitShort("xS2", AtStop, EntryPrice + 2*ATr(14)); } } // 매수매도 off Ep1 = 2/(short+1); Ep2 = 2/(long+1); Ep3 = 2/(sig+1); if Bdate != Bdate[1] Then { S1 = TimeToMinutes(stime); D1 = sdate; } if D1 > 0 then { if sdate == D1 Then TM = TimeToMinutes(stime)-S1; Else TM = TimeToMinutes(stime)+1440-S1; TF = TM%타주기분; if Bdate != Bdate[1] or (Bdate == Bdate[1] and 타주기분 > 1 and TF < TF[1]) or (Bdate == Bdate[1] and 타주기분 > 1 and TM >= TM[1]+타주기분) or (Bdate == Bdate[1] and 타주기분 == 1 and TM > TM[1]) Then { idx = idx + 1; Prexma1 = xma1[1]; Prexma2 = xma2[1]; PreMACDS = MACDS[1]; } if idx <= 1 then { xma1 = C; xma2 = C; MACDV = xma1-xma2; MACDS = MACDV; MACDO = MACDV-MACDS; } else { xma1 = C * EP1 + Prexma1 * (1-EP1); xma2 = C * EP2 + Prexma2 * (1-EP2); MACDV = xma1-xma2; MACDS = MACDV * EP3 + PreMACDS * (1-EP3); MACDO = MACDV-MACDS; } if condition11 == True Then { if Ssystem == true && MACDV > 0 Then Ssystem = False; if Bsystem == true && MACDV < 0 Then Bsystem = false; } } ------------------------------ 제가 짠 수식에선 Bsystem, Ssystem, Fsystem 최소한 셋 중 하나는 true이어야만 진입이 발생할 수 있는데 첨부한 사진을 보면 21:31에 세 조건이 모두 false인데 매도진입이 이뤄졌습니다 =>로그 상의 BS, SS, FS 값이 모두 false인 상황 3개 조건에 한해서만 진입조건을 걸어뒀는데 왜 이런 진입이 일어났는지 아무리 봐도 모르겠어서 살펴봐주시면 감사하겠습니다 감사합니다