OPEN-SOURCE SCRIPT

MFI-RSI Convergence Strategy

142
거래량(Volume)과 가격 모멘텀을 동시에 고려하는 **MFI(Money Flow Index)**는 지지선에서의 '진짜 반등'을 포착하는 데 가장 강력한 도구입니다. 여기에 RSI를 결합하여 모멘텀의 강도까지 확인하는 'Hybrid Volume-Momentum Oscillator' 전략을 작성해 드립니다.

하이브리드 지표의 핵심 메커니즘
MFI(Money Flow Index)의 역할:

MFI는 단순히 가격이 낮아졌는가만 보는 것이 아니라, **'낮은 가격에서 거래량이 터졌는가'**를 계산합니다.

지지선에서 MFI가 20 이하로 떨어진다는 것은 "스마트 머니"가 매집을 준비하는 단계이거나, 투매가 정점에 달해 거래량이 실린 반등이 임박했음을 뜻합니다.

RSI와의 컨버전스(Convergence):

RSI는 가격의 속도를 측정합니다. MFI가 과매도인데 RSI가 아직 높다면, 거래량은 들어오지만 가격의 하락 관성이 여전히 강하다는 뜻입니다.

이 코드의 핵심은 mfi_val <= mfi_low와 rsi_val <= rsi_low가 동시에 만족될 때만 진입하는 것입니다. 이는 거래량 유입 + 하락 관성 둔화가 일치하는 고확률 타점입니다.

리페인팅 차단 및 현실적 시뮬레이션:

ta.mfi와 ta.rsi는 기본적으로 현재 봉의 종가를 기준으로 계산되므로 리페인팅이 발생하지 않습니다.
commission_value=0.05를 통해 거래소 수수료를 반영하여, 잦은 매매로 인한 손실 가능성을 미리 확인할 수 있게 설계했습니다.

Pine Script®
//@version=6 strategy("MFI-RSI Convergence Strategy", overlay=false, // 하단 지표 형태 확인을 위해 false 설정 (차트 위 신호는 별도 plotshape 사용) initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_type=strategy.commission.percent, commission_value=0.05, slippage=1) // --- [ 모듈 1: 사용자 입력 ] --- group_date = "1. 백테스트 기간" start_time = input.time(timestamp("2024-01-01 00:00:00"), "시작일", group=group_date) end_time = input.time(timestamp("2026-12-31 23:59:59"), "종료일", group=group_date) within_window() => time >= start_time and time <= end_time group_mfi = "2. MFI (Volume) 설정" mfi_length = input.int(14, "MFI 기간", minval=1, group=group_mfi) mfi_low = input.int(20, "MFI 과매도 (매수세 유입 대기)", group=group_mfi) mfi_high = input.int(80, "MFI 과매수 (매도세 유입 대기)", group=group_mfi) group_rsi = "3. RSI (Momentum) 설정" rsi_length = input.int(14, "RSI 기간", minval=1, group=group_rsi) rsi_low = input.int(30, "RSI 과매도", group=group_rsi) rsi_high = input.int(70, "RSI 과매수", group=group_rsi) group_risk = "4. 리스크 관리" tp_pct = input.float(3.0, "익절 (%)", step=0.1, group=group_risk) / 100 sl_pct = input.float(1.5, "손절 (%)", step=0.1, group=group_risk) / 100 // --- [ 모듈 2: 데이터 처리 및 지표 계산 ] --- // MFI (가격 + 거래량 가중) mfi_val = ta.mfi(close, mfi_length) // RSI (가격 변동 강도) rsi_val = ta.rsi(close, rsi_length) // --- [ 모듈 3: 전략 로직 ] --- // 매수 조건: MFI와 RSI가 모두 과매도 구간일 때 (강력한 반등 예상 지점) long_condition = (mfi_val <= mfi_low) and (rsi_val <= rsi_low) // 매도 조건: MFI와 RSI가 모두 과매수 구간일 때 short_condition = (mfi_val >= mfi_high) and (rsi_val >= rsi_high) // --- [ 모듈 4: 주문 실행 ] --- if within_window() if long_condition strategy.entry("Long", strategy.long, comment="VLM+MOM Bottom") if short_condition strategy.entry("Short", strategy.short, comment="VLM+MOM Top") // 익절 및 손절 설정 strategy.exit("Ex Long", "Long", limit=strategy.position_avg_price * (1 + tp_pct), stop=strategy.position_avg_price * (1 - sl_pct)) strategy.exit("Ex Short", "Short", limit=strategy.position_avg_price * (1 - tp_pct), stop=strategy.position_avg_price * (1 + sl_pct)) // --- [ 모듈 5: 시각화 (하단 지표 영역) ] --- // 배경 가이드라인 hline(mfi_high, "Upper Boundary", color=color.gray, linestyle=hline.style_dashed) hline(50, "Middle", color=color.new(color.gray, 50)) hline(mfi_low, "Lower Boundary", color=color.gray, linestyle=hline.style_dashed) // 지표 플롯 plot(mfi_val, "MFI (Volume Flow)", color=color.aqua, linewidth=2) plot(rsi_val, "RSI (Momentum)", color=color.yellow, linewidth=1) // 중첩 구간 강조 (Convergence) fill_color = (mfi_val <= mfi_low and rsi_val <= rsi_low) ? color.new(color.green, 70) : (mfi_val >= mfi_high and rsi_val >= rsi_high) ? color.new(color.red, 70) : na bgcolor(fill_color) // 신호 발생 시 하단에 아이콘 표시 plotshape(long_condition, title="Buy Signal", location=location.bottom, color=color.green, style=shape.triangleup, size=size.small) plotshape(short_condition, title="Sell Signal", location=location.top, color=color.red, style=shape.triangledown, size=size.small)

Clause de non-responsabilité

Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.