커뮤니티

시스템

프로필 이미지
달마7
2025-10-02 02:17:20.0
37
글번호 194470
답변완료
안녕하세요 아래식 매수매도전략 완성 부탁드립니다 //@version=5 strategy("YES Language 전략 - Squeeze + Momentum + ADX", overlay=false, default_qty_type=strategy.percent_of_equity, default_qty_value=10) // 사용자 설정 bbLength = input.int(20, title="BB 기간") bbMult = input.float(2.0, title="BB 표준편차 배수") kcLength = input.int(20, title="KC 기간") kcMult = input.float(1.5, title="KC 배수") useTR = input.bool(true, title="켈트너 채널에 TR 사용") adxLength = input.int(14, title="ADX 기간") adxThreshold = input.float(25, title="추세 기준 ADX 수치") // Bollinger Band src = close bbBasis = ta.sma(src, bbLength) bbDev = bbMult * ta.stdev(src, bbLength) bbUpper = bbBasis + bbDev bbLower = bbBasis - bbDev // Keltner Channel kcMA = ta.sma(src, kcLength) kcRange = useTR ? ta.tr : high - low kcRangeMA = ta.sma(kcRange, kcLength) kcUpper = kcMA + kcRangeMA * kcMult kcLower = kcMA - kcRangeMA * kcMult // 스퀴즈 감지 squeezeOn = bbLower > kcLower and bbUpper < kcUpper // 스퀴즈 발생 (변동성 축소) squeezeOff = bbLower < kcLower and bbUpper > kcUpper // 스퀴즈 해제 (변동성 확장) // Momentum 계산 mid = (ta.highest(high, kcLength) + ta.lowest(low, kcLength)) / 2 avgMid = (mid + ta.sma(close, kcLength)) / 2 momentum = ta.linreg(src - avgMid, kcLength, 0) momentumUp = momentum > momentum[1] // 모멘텀 증가 momentumDown = momentum < momentum[1] // 모멘텀 감소 // ADX 계산 adx = ta.adx(adxLength) isTrending = adx > adxThreshold // ADX가 임계치 이상: 추세 발생 중 // === 매수 조건 (YES Language Style) === // 1. 스퀴즈 해제 AND 2. 모멘텀 양수 AND 3. 모멘텀 증가 AND 4. 추세 발생 중 buyCondition = squeezeOff and momentum > 0 and momentumUp and isTrending // === 매도 조건 (YES Language Style) === // 1. 스퀴즈 해제 AND 2. 모멘텀 음수 AND 3. 모멘텀 감소 AND 4. 추세 발생 중 sellCondition = squeezeOff and momentum < 0 and momentumDown and isTrending // --- 포지션 진입 및 반전 (YES Language Style) --- // 매수 조건 충족 시: 롱 포지션 진입 (현재 숏 포지션이 있으면 청산 후 롱으로 반전) if (buyCondition) strategy.entry("YES 롱", strategy.long, comment="YES 롱 진입") // 매도 조건 충족 시: 숏 포지션 진입 (현재 롱 포지션이 있으면 청산 후 숏으로 반전) if (sellCondition) strategy.entry("YES 숏", strategy.short, comment="YES 숏 진입") // 전략 상태 메시지 (차트 표시) plotshape(buyCondition, location=location.belowbar, color=color.lime, style=shape.labelup, text="예스 매수", textcolor=color.black) plotshape(sellCondition, location=location.abovebar, color=color.red, style=shape.labeldown, text="예스 매도", textcolor=color.white) // 추가: 지표 시각화 (선택 사항) plot(momentum, title="Momentum", color=color.new(color.blue, 0)) hline(0, color=color.gray)
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-10-02 13:22:00.0

안녕하세요 예스스탁입니다. input : bbLength(20); input : bbMult(2.0); input : kcLength(20); input : kcMult(1.5); input : useTR(1);#1:TrueRange, 2: h-l input : adxLength(14); input : adxThreshold(25); var : src(0),bbBasis(0),bbDev(0),bbUpper(0),bbLower(0); var : kcMA(0),kcRange(0),kcRangeMA(0),kcUpper(0),kcLower(0); var : squeezeOn(False),squeezeOff(False); var : mid(0),avgMid(0),momentum(0),momentumUp(False),momentumDown(False); var : A(0),isTrending(False),buyCondition(false),sellCondition(False); src = close; bbBasis = ma(src, bbLength); bbDev = bbMult * std(src, bbLength); bbUpper = bbBasis + bbDev; bbLower = bbBasis - bbDev; kcMA = ma(src, kcLength); kcRange = iff(useTR==1,TrueRange, high - low); kcRangeMA = ma(kcRange, kcLength); kcUpper = kcMA + kcRangeMA * kcMult; kcLower = kcMA - kcRangeMA * kcMult; squeezeOn = bbLower > kcLower and bbUpper < kcUpper; squeezeOff = bbLower < kcLower and bbUpper > kcUpper; mid = (highest(high, kcLength) + lowest(low, kcLength)) / 2; avgMid = (mid + ma(close, kcLength)) / 2; momentum = LRL(src - avgMid, kcLength); momentumUp = momentum > momentum[1]; // 모멘텀 증가 momentumDown = momentum < momentum[1]; // 모멘텀 감소 A = adx(adxLength); isTrending = A > adxThreshold; // ADX가 임계치 이상: 추세 발생 중 // === 매수 조건 (YES Language Style) === // 1. 스퀴즈 해제 AND 2. 모멘텀 양수 AND 3. 모멘텀 증가 AND 4. 추세 발생 중 buyCondition = squeezeOff and momentum > 0 and momentumUp and isTrending; // === 매도 조건 (YES Language Style) === // 1. 스퀴즈 해제 AND 2. 모멘텀 음수 AND 3. 모멘텀 감소 AND 4. 추세 발생 중 sellCondition = squeezeOff and momentum < 0 and momentumDown and isTrending; // --- 포지션 진입 및 반전 (YES Language Style) --- // 매수 조건 충족 시: 롱 포지션 진입 (현재 숏 포지션이 있으면 청산 후 롱으로 반전) if buyCondition Then Buy("YES 롱"); // 매도 조건 충족 시: 숏 포지션 진입 (현재 롱 포지션이 있으면 청산 후 숏으로 반전) if sellCondition then Sell("YES 숏"); 즐거운 명절 되시기 바랍니다. > 달마7 님이 쓴 글입니다. > 제목 : 시스템 > 안녕하세요 아래식 매수매도전략 완성 부탁드립니다 //@version=5 strategy("YES Language 전략 - Squeeze + Momentum + ADX", overlay=false, default_qty_type=strategy.percent_of_equity, default_qty_value=10) // 사용자 설정 bbLength = input.int(20, title="BB 기간") bbMult = input.float(2.0, title="BB 표준편차 배수") kcLength = input.int(20, title="KC 기간") kcMult = input.float(1.5, title="KC 배수") useTR = input.bool(true, title="켈트너 채널에 TR 사용") adxLength = input.int(14, title="ADX 기간") adxThreshold = input.float(25, title="추세 기준 ADX 수치") // Bollinger Band src = close bbBasis = ta.sma(src, bbLength) bbDev = bbMult * ta.stdev(src, bbLength) bbUpper = bbBasis + bbDev bbLower = bbBasis - bbDev // Keltner Channel kcMA = ta.sma(src, kcLength) kcRange = useTR ? ta.tr : high - low kcRangeMA = ta.sma(kcRange, kcLength) kcUpper = kcMA + kcRangeMA * kcMult kcLower = kcMA - kcRangeMA * kcMult // 스퀴즈 감지 squeezeOn = bbLower > kcLower and bbUpper < kcUpper // 스퀴즈 발생 (변동성 축소) squeezeOff = bbLower < kcLower and bbUpper > kcUpper // 스퀴즈 해제 (변동성 확장) // Momentum 계산 mid = (ta.highest(high, kcLength) + ta.lowest(low, kcLength)) / 2 avgMid = (mid + ta.sma(close, kcLength)) / 2 momentum = ta.linreg(src - avgMid, kcLength, 0) momentumUp = momentum > momentum[1] // 모멘텀 증가 momentumDown = momentum < momentum[1] // 모멘텀 감소 // ADX 계산 adx = ta.adx(adxLength) isTrending = adx > adxThreshold // ADX가 임계치 이상: 추세 발생 중 // === 매수 조건 (YES Language Style) === // 1. 스퀴즈 해제 AND 2. 모멘텀 양수 AND 3. 모멘텀 증가 AND 4. 추세 발생 중 buyCondition = squeezeOff and momentum > 0 and momentumUp and isTrending // === 매도 조건 (YES Language Style) === // 1. 스퀴즈 해제 AND 2. 모멘텀 음수 AND 3. 모멘텀 감소 AND 4. 추세 발생 중 sellCondition = squeezeOff and momentum < 0 and momentumDown and isTrending // --- 포지션 진입 및 반전 (YES Language Style) --- // 매수 조건 충족 시: 롱 포지션 진입 (현재 숏 포지션이 있으면 청산 후 롱으로 반전) if (buyCondition) strategy.entry("YES 롱", strategy.long, comment="YES 롱 진입") // 매도 조건 충족 시: 숏 포지션 진입 (현재 롱 포지션이 있으면 청산 후 숏으로 반전) if (sellCondition) strategy.entry("YES 숏", strategy.short, comment="YES 숏 진입") // 전략 상태 메시지 (차트 표시) plotshape(buyCondition, location=location.belowbar, color=color.lime, style=shape.labelup, text="예스 매수", textcolor=color.black) plotshape(sellCondition, location=location.abovebar, color=color.red, style=shape.labeldown, text="예스 매도", textcolor=color.white) // 추가: 지표 시각화 (선택 사항) plot(momentum, title="Momentum", color=color.new(color.blue, 0)) hline(0, color=color.gray)