커뮤니티
문의 드립니다
수식오류 수정 부탁드립니다.
input: ma_fast_period(10); // "Fast MA Period"
input: ma_slow_period(30); // "Slow MA Period"
input: rsi_period(14); // "RSI Period"
input: rsi_oversold(30); // "RSI Oversold Level"
input: rsi_overbought(70); // "RSI Overbought Level"
input: adx_period(14); // "ADX Period"
input: adx_threshold(25); // "ADX Trend Threshold"
input: bb_period(20); // "Bollinger Band Period"
input: bb_deviation(2); // "Bollinger Band Deviation"
input: volume_ma_period(20); // "Volume MA Period"
input: use_trend_filter(true); // "Use Trend Filter"
input: use_momentum_filter(true);// "Use Momentum Filter"
input: use_volatility_filter(true); // "Use Volatility Filter"
var: ma_fast(0), ma_slow(0), rsi_value(0), adx_value(0);
var: bb_upper(0), bb_lower(0), bb_middle(0), volume_ma(0);
var: trend_direction(0), momentum_signal(0), volatility_signal(0);
var: exit_signal_long(false), exit_signal_short(false);
// ===== 다중 지표 계산 =====
// 1. 이동평균 (추세)
ma_fast = Average(close, ma_fast_period);
ma_slow = Average(close, ma_slow_period);
// 2. RSI (모멘텀)
rsi_value = RSI(rsi_period);
// 3. ADX (추세 강도)
adx_value = ADX(adx_period);
// 4. 볼린저 밴드 (변동성)
Input : Period(20), MultiD(2);
var : MAv(0),BBup(0),BBdn(0);
bb_middle = Average(close, bb_period);
//bb_upper = bb_middle + bb_deviation * StdDev(close, bb_period);
//bb_lower = bb_middle - bb_deviation * StdDev(close, bb_period);
bb_upper = BollBandUp(Period,bb_deviation);
bb_lower = BollBandDown(Period,bb_deviation);
// 5. 볼륨 지표
volume_ma = Average(volume, volume_ma_period);
// ===== 다중 필터 신호 계산 =====
// 추세 필터
if use_trend_filter Then Begin
if ma_fast < ma_slow Then
trend_direction = -1;
Else if ma_fast > ma_slow Then
trend_direction = 1;
Else
trend_direction = 0;
End Else
trend_direction = 1; // 필터 사용 안할 때는 항상 true
// 모멘텀 필터
if use_momentum_filter Then Begin
if rsi_value < rsi_oversold Then
momentum_signal = -1;
Else if rsi_value > rsi_overbought Then
momentum_signal = 1;
Else
momentum_signal = 0;
End Else
momentum_signal = 0; // 필터 사용 안할 때는 영향 없음
// 변동성 필터
if use_volatility_filter Then Begin
if close > bb_upper Then
volatility_signal = 1;
Else if close < bb_lower Then
volatility_signal = -1;
Else
volatility_signal = 0;
End Else
volatility_signal = 0;
// ===== 다중 지표 기반 청산 신호 =====
// 롱 포지션 청산 조건
exit_signal_long = false;
if MarketPosition == 1 Then Begin
// 조건 1: 추세 전환 (하락 추세)
condition1 == (trend_direction = -1);
// 조건 2: 모멘텀 약화 (RSI 과매수에서 하락)
condition2 == (momentum_signal = -1) or (rsi_value < 50);
// 조건 3: 변동성 확대 (밴드 상단 돌파 후 하락)
condition3 == (volatility_signal = -1) or (close < bb_middle);
// 조건 4: 추세 강도 약화 (ADX 하락)
condition4 = (adx_value < adx_threshold);
// 조건 5: 거래량 감소 (추세 약화 확인)
condition5 == (volume < volume_ma);
// 다중 조건 조합 (3개 이상 충족 시 청산)
if condition1 + condition2 + condition3 + condition4 + condition5 >= 3 Then
exit_signal_long = true;
if exit_signal_long Then
ExitLong("Multi Indicator Exit Long");
End;
// 숏 포지션 청산 조건
exit_signal_short = false;
if MarketPosition == -1 Then Begin
// 조건 1: 추세 전환 (상승 추세)
condition1 = (trend_direction = 1);
// 조건 2: 모멘텀 강화 (RSI 과매도에서 상승)
condition2 = (momentum_signal = 1) or (rsi_value > 50);
// 조건 3: 변동성 확대 (밴드 하단 돌파 후 상승)
condition3 = (volatility_signal = 1) or (close > bb_middle);
// 조건 4: 추세 강도 약화 (ADX 하락)
condition4 = (adx_value < adx_threshold);
// 조건 5: 거래량 감소 (추세 약화 확인)
condition5 = (volume < volume_ma);
// 다중 조건 조합 (3개 이상 충족 시 청산)
if (condition1 + condition2 + condition3 + condition4 + condition5) >= 3 Then
exit_signal_short = true;
if exit_signal_short Then
ExitShort("Multi Indicator Exit Short");
End;
// ===== 고급: 가중치 기반 점수 시스템 =====
var: long_score(0), short_score(0);
if MarketPosition == 1 Then Begin
long_score = 0;
if trend_direction = -1 then long_score = long_score + 2;
if momentum_signal = -1 then long_score = long_score + 2;
if volatility_signal = -1 then long_score = long_score + 1;
if adx_value < adx_threshold then long_score = long_score + 1;
if volume < volume_ma then long_score = long_score + 1;
if long_score >= 5 Then
ExitLong("Weighted Score Exit Long");
End;
if MarketPosition == -1 Then Begin
short_score = 0;
if trend_direction = 1 then short_score = short_score + 2;
if momentum_signal = 1 then short_score = short_score + 2;
if volatility_signal = 1 then short_score = short_score + 1;
if adx_value < adx_threshold then short_score = short_score + 1;
if volume < volume_ma then short_score = short_score + 1;
if short_score >= 5 Then
ExitShort("Weighted Score Exit Short");
End;
답변 1
예스스탁 예스스탁 답변
2025-11-17 16:18:29