커뮤니티

안녕하세요. 문제가 있는데 어떻게 해결해야할까요?

프로필 이미지
최태수
2025-08-25 21:14:35
112
글번호 193500
답변완료

첨부 이미지

담당자님 안녕하세요. 무더위에 항상 고생 많으십니다. 예스트레이더에서 SuperTrend와 EMA(12,26) 조합으로 숏 전용 전략을 테스트하고 있습니다. 현재 사용 중인 전략의 주요 로직은 다음과 같습니다. 진입 조건 포지션 없음 (MarketPosition = 0) 1.EMA12 < EMA26 (데드크로스 상태) 2.종가 < SuperTrend 라인 청산 조건 숏 포지션 보유 중 (MarketPosition = -1) 1.EMA12 > EMA26 (골든크로스 상태) 2.종가 > SuperTrend 라인 그런데 실전 차트에서 다음과 같은 문제가 발생합니다. 청산 조건이 충족된 이전 봉에서 바로 청산되지 않고, 한두 봉 뒤에서야 청산됩니다. 어떤 구간에서는 EMA 데드크로스와 SuperTrend 매도 조건이 순서만 달랐을 뿐 모두 발생했는데도, 진입이 전혀 이루어지지 않습니다. 첨부한 차트 이미지를 보시면, 첫 번째 이미지는 EMA와 SuperTrend 매도 신호가 모두 발생했지만 진입이 전혀 이뤄지지 않은 사례입니다. 두 번째 이미지는 청산 조건이 전전봉에서 충족됐지만 실제 청산은 그 다음 봉에서 이뤄진 사례입니다. 제가 적용한 코딩도 남겨드리겠습니다. Inputs: factor (3), // SuperTrend ATR 배수 AtrPeriod (14), // SuperTrend ATR 기간 shortLen (12), // EMA 단기 기간 longLen (26); // EMA 장기 기간 Vars: src (0), trv (0), atrv (0), upperBand (0), lowerBand (0), prevUB (0), prevLB (0), dir (0), supertrend (0), emaShort (0), emaLong (0); // === 1) SuperTrend 계산 === if CurrentBar > 1 then { src = (High + Low) / 2; trv = MaxList(High - Low, MaxList(Abs(High - Close[1]), Abs(Low - Close[1]))); atrv = EMA(trv, AtrPeriod); upperBand = src + factor * atrv; lowerBand = src - factor * atrv; prevUB = upperBand[1]; prevLB = lowerBand[1]; if (lowerBand <= prevLB and Close[1] >= prevLB) then lowerBand = prevLB; if (upperBand >= prevUB and Close[1] <= prevUB) then upperBand = prevUB; if Close > upperBand then dir = 1; else if Close < lowerBand then dir = -1; if dir == 1 then supertrend = lowerBand; else supertrend = upperBand; } // === 2) EMA 계산 === emaShort = EMA(Close, shortLen); emaLong = EMA(Close, longLen); // === 3) 숏 진입·청산만 === // 숏 진입: 포지션 없고 EMA < & 가격 < SuperTrend if MarketPosition == 0 and emaShort < emaLong and Close < supertrend then { Sell("ShortEntry"); } // 숏 청산: 숏 보유 중 EMA > & 가격 > SuperTrend if MarketPosition < 0 and emaShort > emaLong and Close > supertrend then { ExitShort("ShortExit"); }
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-08-26 14:48:58

안녕하세요 예스스탁입니다. 수식을 적용해 보았지만 첨부하신 모두 정상적으로 신호가 발생하고 있습니다. 지표와 비교해도 조건이 신호 발생봉과 신호가 다르지 않고 늦게 발생하거나 하지 않습니다. 아래식 지표식으로 작성해 비교해 보시기 바랍니다. macd로 보셔도 되지만 한번에 그리기 위해 단기/장기 지수이평을 슈퍼트렌드와 함께 그린식입니다. Inputs: factor (3), // SuperTrend ATR 배수 AtrPeriod (14), // SuperTrend ATR 기간 shortLen (12), // EMA 단기 기간 longLen (26); // EMA 장기 기간 Vars: src (0), trv (0), atrv (0), upperBand (0), lowerBand (0), prevUB (0), prevLB (0), dir (0), supertrend (0), emaShort (0), emaLong (0); // === 1) SuperTrend 계산 === if CurrentBar > 1 then { src = (High + Low) / 2; trv = MaxList(High - Low, MaxList(Abs(High - Close[1]), Abs(Low - Close[1]))); atrv = EMA(trv, AtrPeriod); upperBand = src + factor * atrv; lowerBand = src - factor * atrv; prevUB = upperBand[1]; prevLB = lowerBand[1]; if (lowerBand <= prevLB and Close[1] >= prevLB) then lowerBand = prevLB; if (upperBand >= prevUB and Close[1] <= prevUB) then upperBand = prevUB; if Close > upperBand then dir = 1; else if Close < lowerBand then dir = -1; if dir == 1 then supertrend = lowerBand; else supertrend = upperBand; } // === 2) EMA 계산 === emaShort = EMA(Close, shortLen); emaLong = EMA(Close, longLen); Plot1(supertrend); plot2(emaShort); plot3(emaLong); 즐거운 하루되세요 > 최태수 님이 쓴 글입니다. > 제목 : 안녕하세요. 문제가 있는데 어떻게 해결해야할까요? > 담당자님 안녕하세요. 무더위에 항상 고생 많으십니다. 예스트레이더에서 SuperTrend와 EMA(12,26) 조합으로 숏 전용 전략을 테스트하고 있습니다. 현재 사용 중인 전략의 주요 로직은 다음과 같습니다. 진입 조건 포지션 없음 (MarketPosition = 0) 1.EMA12 < EMA26 (데드크로스 상태) 2.종가 < SuperTrend 라인 청산 조건 숏 포지션 보유 중 (MarketPosition = -1) 1.EMA12 > EMA26 (골든크로스 상태) 2.종가 > SuperTrend 라인 그런데 실전 차트에서 다음과 같은 문제가 발생합니다. 청산 조건이 충족된 이전 봉에서 바로 청산되지 않고, 한두 봉 뒤에서야 청산됩니다. 어떤 구간에서는 EMA 데드크로스와 SuperTrend 매도 조건이 순서만 달랐을 뿐 모두 발생했는데도, 진입이 전혀 이루어지지 않습니다. 첨부한 차트 이미지를 보시면, 첫 번째 이미지는 EMA와 SuperTrend 매도 신호가 모두 발생했지만 진입이 전혀 이뤄지지 않은 사례입니다. 두 번째 이미지는 청산 조건이 전전봉에서 충족됐지만 실제 청산은 그 다음 봉에서 이뤄진 사례입니다. 제가 적용한 코딩도 남겨드리겠습니다. Inputs: factor (3), // SuperTrend ATR 배수 AtrPeriod (14), // SuperTrend ATR 기간 shortLen (12), // EMA 단기 기간 longLen (26); // EMA 장기 기간 Vars: src (0), trv (0), atrv (0), upperBand (0), lowerBand (0), prevUB (0), prevLB (0), dir (0), supertrend (0), emaShort (0), emaLong (0); // === 1) SuperTrend 계산 === if CurrentBar > 1 then { src = (High + Low) / 2; trv = MaxList(High - Low, MaxList(Abs(High - Close[1]), Abs(Low - Close[1]))); atrv = EMA(trv, AtrPeriod); upperBand = src + factor * atrv; lowerBand = src - factor * atrv; prevUB = upperBand[1]; prevLB = lowerBand[1]; if (lowerBand <= prevLB and Close[1] >= prevLB) then lowerBand = prevLB; if (upperBand >= prevUB and Close[1] <= prevUB) then upperBand = prevUB; if Close > upperBand then dir = 1; else if Close < lowerBand then dir = -1; if dir == 1 then supertrend = lowerBand; else supertrend = upperBand; } // === 2) EMA 계산 === emaShort = EMA(Close, shortLen); emaLong = EMA(Close, longLen); // === 3) 숏 진입·청산만 === // 숏 진입: 포지션 없고 EMA < & 가격 < SuperTrend if MarketPosition == 0 and emaShort < emaLong and Close < supertrend then { Sell("ShortEntry"); } // 숏 청산: 숏 보유 중 EMA > & 가격 > SuperTrend if MarketPosition < 0 and emaShort > emaLong and Close > supertrend then { ExitShort("ShortExit"); }