가변지수 동적 이동평균 다층 이익 추세 추적 전략


생성 날짜: 2025-09-10 11:14:13 마지막으로 수정됨: 2025-11-21 11:55:25
복사: 0 클릭수: 29
avatar of ianzeng123 ianzeng123
2
집중하다
319
수행원

가변지수 동적 이동평균 다층 이익 추세 추적 전략

개요

이 전략은 변수 지수 동적 평균 ((VIDYA) 지표와 부린 밴드 ((Bollinger Bands) 를 결합한 트렌드 추적 시스템이며, 동시에 다단계 정지 메커니즘을 통합한다. 전통적인 트렌드 전략과 달리, 이 시스템은 더 적응적인 수익을 얻는 방법을 채택하고, 고유한 ATR 기준과 비율 목표를 통해 다단계 공백 위치를 구분한다. 이 전략의 혁신은 다단계 정지 방법을 채택하고, 특히 공백 거래에 대해 더 급진적인 비율 곱셈을 채택하고, 이러한 유연성은 시장의 변동성과 트렌드 강도에 따라 거래 관리 및 수익 분배를 최적화하는 데 도움이됩니다.

전략 원칙

전략의 핵심은 빠른 속도와 느린 속도 두 가지의 VIDYA 지표를 사용하여 가격 추세를 분석하고 시장의 변동성을 고려하는 것입니다. VIDYA 지표의 계산 공식은 다음과 같습니다. 평형 인자 (α) = 2/ (周期+1) VIDYA (t) = α * k * 가격 (t) + (1 - α * k) * VIDYA (t-1) 여기서 k = 드 동력 진동기 (MO) 100

브린 밴드는 변동률 필터로 사용된다: 위 궤도 = MA + (K * 표준 차) 하단 궤도 = MA - (K * 표준 차)

입장 조건:

  • 다수: 가격이 느린VIDYA를 돌파하고 빠른VIDYA가 상승하고, 가격도 브린을 돌파하고
  • 공백: 가격이 느린VIDYA와 빠른VIDYA의 하향 트렌드를 넘어 부린의 하향 트렌드를 넘어갑니다

다층 차단 장치는 다음과 같습니다:

  1. ATR 기반의 정지
  2. 비율에 따라 정지
  3. 공백 거래는 곱셈을 사용하여 정지 비율을 확대합니다.

전략적 이점

  1. 동적 적응력:VIDYA 지표는 시장의 변동에 따라 자동으로 조정되며, 전통적인 평균선보다 더 민감하다.
  2. 리스크 관리가 잘 되어있으며, 다단계 차단 장치가 다양한 가격 수준에서 수익을 고정시킬 수 있습니다.
  3. 차별화 처리: 빈 위치에 대해 다른 차단 전략을 적용하여 시장 특성에 더 적합합니다.
  4. 파동율 필터링: 부린띠를 사용하여 가짜 뚫림 신호를 필터링할 수 있다.
  5. 매개 변수 유연성: 다른 시장 조건에 따라 매개 변수를 조정할 수 있다

전략적 위험

  1. 위기 시장 위험: 수평 시장에서 잘못된 신호가 발생할 수 있습니다.
  2. 슬라이드 포인트 영향: 여러 개의 정지가 슬라이드 포인트로 인해 실행 가격의 편차로 이어질 수 있다.
  3. 매개 변수 의존성: 다른 시장 환경에 따라 매개 변수를 자주 조정해야 할 수 있습니다.
  4. 시스템 복잡성: 여러 계층의 차단 메커니즘이 전략의 복잡성을 증가시킵니다.
  5. 자금 관리 압력: 여러 개의 상장 중단으로 인해 상장 관리의 어려움이 증가할 수 있습니다.

전략 최적화 방향

  1. 동적 변수 조정: 시장 조건에 따라 자동으로 조정되는 적응 변수 시스템을 개발할 수 있습니다.
  2. 시장 환경 인식: 시장 환경 판단 모듈을 추가하여 다른 시장 조건에서 다른 매개 변수를 사용합니다.
  3. 손해 차단 최적화: 동적 손해 차단 메커니즘을 증가시키고 위험 제어 능력을 향상시킵니다.
  4. 신호 필터링: 트래픽 증가와 같은 보조 지표, 신호 신뢰성을 향상
  5. 포지션 관리: 더 똑똑한 포지션 배분 알고리즘 개발

요약하다

이 전략은 VIDYA 지표의 동적 적응성과 브린 밴드의 변동률 필터 기능을 결합하여 포괄적인 트렌드 추적 시스템을 만듭니다. 다층의 차단 메커니즘과 차별화된 다중공간 처리는 좋은 수익성과 위험 제어 능력을 갖춘다. 그러나 사용자는 시장 환경의 변화에 주의를 기울이고 적절한 변수를 조정하고 완벽한 자금 관리 시스템을 구축해야합니다.

전략 소스 코드
/*backtest
start: 2025-01-01 00:00:00
end: 2025-09-08 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT","balance":500000}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PresentTrading

// This strategy, "VIDYA ProTrend Multi-Tier Profit," is a trend-following system that utilizes fast and slow VIDYA indicators 
// to identify entry and exit points based on the direction and strength of the trend. 
// It incorporates Bollinger Bands as a volatility filter and features a multi-step take profit mechanism, 
// with adjustable ATR-based and percentage-based profit targets for both long and short positions. 
// The strategy allows for more aggressive take profit settings for short trades, making it adaptable to varying market conditions.

//@version=5
strategy("VIDYA ProTrend Multi-Tier Profit", overlay=true)


// User-defined inputs
tradeDirection = input.string(title="Trading Direction", defval="Both", options=["Long", "Short", "Both"])
fastVidyaLength = input.int(10, title="Fast VIDYA Length", minval=1)
slowVidyaLength = input.int(30, title="Slow VIDYA Length", minval=1)
minSlopeThreshold = input.float(0.05, title="Minimum VIDYA Slope Threshold", step=0.01)

// Bollinger Bands Inputs
bbLength = input.int(20, title="Bollinger Bands Length", minval=1)
bbMultiplier = input.float(1.0, title="Bollinger Bands Multiplier", step=0.1)

// Multi-Step Take Profit Settings
group_tp = "Multi-Step Take Profit"
useMultiStepTP = input.bool(true, title="Enable Multi-Step Take Profit", group=group_tp)
tp_direction = input.string(title="Take Profit Direction", defval="Both", options=["Long", "Short", "Both"], group=group_tp)
atrLengthTP =  input.int(14, title="ATR Length", group=group_tp)


// ATR-based Take Profit Steps
atrMultiplierTP1 = input.float(2.618, title="ATR Multiplier for TP 1", group=group_tp)
atrMultiplierTP2 = input.float(5.0, title="ATR Multiplier for TP 2", group=group_tp)
atrMultiplierTP3 = input.float(10.0, title="ATR Multiplier for TP 3", group=group_tp)

// Short Position Multiplier for Take Profit Percentages
shortTPPercentMultiplier = input.float(1.5, title="Short TP Percent Multiplier", group=group_tp)

// Percentage-based Take Profit Steps (Long)
tp_level_percent1 = input.float(title="Take Profit Level 1 (%)", defval=3.0, group=group_tp)
tp_level_percent2 = input.float(title="Take Profit Level 2 (%)", defval=8.0, group=group_tp)
tp_level_percent3 = input.float(title="Take Profit Level 3 (%)", defval=17.0, group=group_tp)

// Percentage-based Take Profit Allocation (Long)
tp_percent1 = input.float(title="Take Profit Percent 1 (%)", defval=12.0, group=group_tp)
tp_percent2 = input.float(title="Take Profit Percent 2 (%)", defval=8.0, group=group_tp)
tp_percent3 = input.float(title="Take Profit Percent 3 (%)", defval=10.0, group=group_tp)

// ATR-based Take Profit Percent Allocation (Long)
tp_percentATR1 = input.float(title="ATR TP Percent 1 (%)", defval=10.0, group=group_tp)
tp_percentATR2 = input.float(title="ATR TP Percent 2 (%)", defval=10.0, group=group_tp)
tp_percentATR3 = input.float(title="ATR TP Percent 3 (%)", defval=10.0, group=group_tp)

// Short position percentage allocations using the multiplier
tp_percent1_short = tp_percent1 * shortTPPercentMultiplier
tp_percent2_short = tp_percent2 * shortTPPercentMultiplier
tp_percent3_short = tp_percent3 * shortTPPercentMultiplier

tp_percentATR1_short = tp_percentATR1 * shortTPPercentMultiplier
tp_percentATR2_short = tp_percentATR2 * shortTPPercentMultiplier
tp_percentATR3_short = tp_percentATR3 * shortTPPercentMultiplier

// VIDYA Calculation Function
calcVIDYA(src, length) =>
    alpha = 2 / (length + 1)
    momm = ta.change(src)
    m1 = momm >= 0.0 ? momm : 0.0
    m2 = momm < 0.0 ? -momm : 0.0
    sm1 = math.sum(m1, length)
    sm2 = math.sum(m2, length)
    chandeMO = nz(100 * (sm1 - sm2) / (sm1 + sm2))
    k = math.abs(chandeMO) / 100
    var float vidya = na
    vidya := na(vidya[1]) ? src : (alpha * k * src + (1 - alpha * k) * vidya[1])
    vidya

// Calculate VIDYAs
fastVIDYA = calcVIDYA(close, fastVidyaLength)
slowVIDYA = calcVIDYA(close, slowVidyaLength)

// Bollinger Bands Calculation
[bbUpper, bbBasis, bbLower] = ta.bb(close, bbLength, bbMultiplier)

// Manual Slope Calculation (price difference over time)
calcSlope(current, previous, length) =>
    (current - previous) / length

// Slope of fast and slow VIDYA (comparing current value with value 'length' bars ago)
fastSlope = calcSlope(fastVIDYA, fastVIDYA[fastVidyaLength], fastVidyaLength)
slowSlope = calcSlope(slowVIDYA, slowVIDYA[slowVidyaLength], slowVidyaLength)

// Conditions for long entry with Bollinger Bands filter
longCondition = close > slowVIDYA and fastSlope > slowSlope and fastSlope > minSlopeThreshold and slowSlope > 1/2*minSlopeThreshold and close > bbUpper

// Conditions for short entry with Bollinger Bands filter
shortCondition = close < slowVIDYA and fastSlope < slowSlope and fastSlope < -minSlopeThreshold and slowSlope < -1/2*minSlopeThreshold and close < bbLower

// Exit conditions (opposite crossovers or flat slopes)
exitLongCondition = fastSlope < -minSlopeThreshold and slowSlope < -1/2*minSlopeThreshold or shortCondition
exitShortCondition = fastSlope > minSlopeThreshold and slowSlope > 1/2*minSlopeThreshold or longCondition

// Entry and Exit logic with trading direction
if (longCondition) and (strategy.position_size == 0) and (tradeDirection == "Long" or tradeDirection == "Both")
    strategy.order("Long", strategy.long)

if (exitLongCondition) and strategy.position_size > 0 and (tradeDirection == "Long" or tradeDirection == "Both")
    strategy.close("Long")

if (shortCondition) and (strategy.position_size == 0) and (tradeDirection == "Short" or tradeDirection == "Both")
    strategy.order("Short", strategy.short)

if (exitShortCondition) and strategy.position_size < 0 and (tradeDirection == "Short" or tradeDirection == "Both")
    strategy.close("Short")


if useMultiStepTP
    if strategy.position_size > 0 and (tp_direction == "Long" or tp_direction == "Both")
        // ATR-based Take Profit (Long)
        tp_priceATR1_long = strategy.position_avg_price + atrMultiplierTP1 * ta.atr(atrLengthTP)
        tp_priceATR2_long = strategy.position_avg_price + atrMultiplierTP2 * ta.atr(atrLengthTP)
        tp_priceATR3_long = strategy.position_avg_price + atrMultiplierTP3 * ta.atr(atrLengthTP)
        
        // Percentage-based Take Profit (Long)
        tp_pricePercent1_long = strategy.position_avg_price * (1 + tp_level_percent1 / 100)
        tp_pricePercent2_long = strategy.position_avg_price * (1 + tp_level_percent2 / 100)
        tp_pricePercent3_long = strategy.position_avg_price * (1 + tp_level_percent3 / 100)

        // Execute ATR-based exits for Long
        strategy.exit("TP ATR 1 Long", from_entry="Long", qty_percent=tp_percentATR1, limit=tp_priceATR1_long)
        strategy.exit("TP ATR 2 Long", from_entry="Long", qty_percent=tp_percentATR2, limit=tp_priceATR2_long)
        strategy.exit("TP ATR 3 Long", from_entry="Long", qty_percent=tp_percentATR3, limit=tp_priceATR3_long)
        
        // Execute Percentage-based exits for Long
        strategy.exit("TP Percent 1 Long", from_entry="Long", qty_percent=tp_percent1, limit=tp_pricePercent1_long)
        strategy.exit("TP Percent 2 Long", from_entry="Long", qty_percent=tp_percent2, limit=tp_pricePercent2_long)
        strategy.exit("TP Percent 3 Long", from_entry="Long", qty_percent=tp_percent3, limit=tp_pricePercent3_long)

    if strategy.position_size < 0 and (tp_direction == "Short" or tp_direction == "Both")
        // ATR-based Take Profit (Short) - using the same ATR levels as long
        tp_priceATR1_short = strategy.position_avg_price - atrMultiplierTP1 * ta.atr(atrLengthTP)
        tp_priceATR2_short = strategy.position_avg_price - atrMultiplierTP2 * ta.atr(atrLengthTP)
        tp_priceATR3_short = strategy.position_avg_price - atrMultiplierTP3 * ta.atr(atrLengthTP)
        
        // Percentage-based Take Profit (Short) - using the same levels, but more aggressive percentages
        tp_pricePercent1_short = strategy.position_avg_price * (1 - tp_level_percent1 / 100)
        tp_pricePercent2_short = strategy.position_avg_price * (1 - tp_level_percent2 / 100)
        tp_pricePercent3_short = strategy.position_avg_price * (1 - tp_level_percent3 / 100)

        // Execute ATR-based exits for Short (using the percentage multiplier for short)
        strategy.exit("TP ATR 1 Short", from_entry="Short", qty_percent=tp_percentATR1_short, limit=tp_priceATR1_short)
        strategy.exit("TP ATR 2 Short", from_entry="Short", qty_percent=tp_percentATR2_short, limit=tp_priceATR2_short)
        strategy.exit("TP ATR 3 Short", from_entry="Short", qty_percent=tp_percentATR3_short, limit=tp_priceATR3_short)
        
        // Execute Percentage-based exits for Short
        strategy.exit("TP Percent 1 Short", from_entry="Short", qty_percent=tp_percent1_short, limit=tp_pricePercent1_short)
        strategy.exit("TP Percent 2 Short", from_entry="Short", qty_percent=tp_percent2_short, limit=tp_pricePercent2_short)
        strategy.exit("TP Percent 3 Short", from_entry="Short", qty_percent=tp_percent3_short, limit=tp_pricePercent3_short)
// Plot VIDYAs
plot(fastVIDYA, color=color.green, title="Fast VIDYA")
plot(slowVIDYA, color=color.red, title="Slow VIDYA")