볼린저 밴드와 ATR을 기반으로 한 다단계 지능형 동적 추적 손절매 전략

BB ATR MA SMA EMA SMMA WMA VWMA SD
생성 날짜: 2024-12-11 14:52:24 마지막으로 수정됨: 2024-12-11 14:52:24
복사: 2 클릭수: 363
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

볼린저 밴드와 ATR을 기반으로 한 다단계 지능형 동적 추적 손절매 전략

개요

이 전략은 부린 띠와 ATR 지표를 기반으로 한 지능형 거래 시스템으로, 다단계 스톱 로즈 메커니즘을 결합한다. 전략은 주로 부린 띠 하향 궤도 근처의 반전 신호를 식별하여 다중 입장을 수행하며, 동적 추적 스톱 로즈 방법을 사용하여 위험을 관리한다. 시스템은 20%의 수익 목표와 12%의 중지 지점을 설계했으며, 동적 추적 스톱 로즈를 ATR 지표와 결합하여 이익을 보호하면서 트렌드에 충분한 개발 공간을 제공합니다.

전략 원칙

전략의 핵심 논리는 다음과 같은 핵심 부분으로 구성됩니다.

  1. 진입 조건: 빨간색 이 부린 띠 아래로 닿은 뒤에 녹색 이 나타나는 것을 요구한다. 이런 형태는 보통 역전 신호를 예고한다.
  2. 이동 평균 선택: 여러 이동 평균 유형을 지원합니다 (SMA, EMA, SMMA, WMA, VWMA), 20주기 SMA를 기본으로 사용합니다.
  3. 브린 대역 변수: 1.5배의 표준 차이를 대역폭으로 사용한다. 이 설정은 전통적인 2배의 표준 차이를 보다 보수적이다.
  4. 스 메커니즘: 20%의 초기 수익 목표를 설정하십시오.
  5. 손실 메커니즘: 12%의 고정 손실 지점 보호 자금을 설정한다.
  6. 동적 추적 손실:
    • ATR 트래킹 스톱로스가 목표 수익 수준에 도달하면 활성화됩니다.
    • 부린 띠를 터치한 후 ATR 동적 추적 중지
    • ATR 곱하기 동적 조정 추적 스톱 거리

전략적 이점

  1. 다단계 위험 관리:
    • 고정 스톱 리스 보호 자본
    • 동적 추적 중지 손실 잠금 이익
    • 부린 벨트 선로에 의해 유발된 동적 정지 (Dynamic Stop) 는 추가적인 보호를 제공합니다.
  2. 유연한 이동 평균 선택으로 전략이 다양한 시장 환경에 적응할 수 있습니다.
  3. ATR 지표와 결합된 동적 추적 스톱 로즈는 시장의 변동성에 따라 자동으로 조정되어 조기 퇴출을 방지할 수 있습니다.
  4. 입시 신호는 가격 형태와 기술 지표를 결합하여 신호의 신뢰성을 향상시킵니다.
  5. 포지션 관리 및 거래 비용 설정을 지원하여 실제 거래 환경에 가깝습니다.

전략적 위험

  1. 급격한 변동이 거래비용을 높여 거래 빈도를 높일 수 있다.
  2. 12%의 고정된 스톱 리스는 일부 높은 변동성 시장에서 너무 작을 수 있습니다.
  3. 브린띠 신호는 트렌드 시장에서 가짜 신호를 생성할 수 있다.
  4. ATR 추적 중단은 급격한 변동이 있을 때 더 큰 철수로 이어질 수 있다. 완화 조치:
  • 더 큰 시간 주기에서 사용하는 것이 좋습니다.
  • 특정 품종 특성에 따라 스톱 손실 비율을 조정할 수 있습니다.
  • 트렌드 필터를 추가하여 가짜 신호를 줄이는 것을 고려하십시오.
  • 다양한 시장 환경에 맞게 ATR의 배수를 동적으로 조정하는 방법

전략 최적화 방향

  1. 입시 최적화:
  • 거래량 확인 메커니즘 추가
  • 트렌드 강도 지표 필터링 신호를 추가
  • 동력 지표 보조 판단을 포함하는 것을 고려하십시오.
  1. 스탠드 로즈 최적화
  • ATR 기반의 다이내믹 스톱로 고정 스톱을 변경합니다.
  • 자율적 제약 알고리즘 개발
  • 변동율에 따라 역동적으로 조정된 스톱디스펜스
  1. 이동 평균 최적화:
  • 다른 주기 조합을 테스트합니다.
  • 적응주기 연구
  • 이동 평균의 대안으로 가격 행동을 사용하는 것을 고려하십시오.
  1. 포지션 관리 최적화:
  • 변동률 기반의 포지션 관리 시스템을 개발
  • 배치별로 위치를 구축하고 축소하기 위한 메커니즘을 구현합니다.
  • 리스크 컨트롤에 가입하세요

요약하다

이 전략은 브린 띠와 ATR 지표를 통해 다층 거래 시스템을 구축하고 입시, 중지 손실 및 수익 결제 등에 대해 동적 관리 방법을 사용합니다. 전략의 장점은 완벽한 위험 제어 시스템과 시장 변동에 대한 적응 능력입니다. 제안 된 최적화 방향을 통해 전략에는 큰 향상 공간이 있습니다. 특히 더 큰 시간 주기에 적합하며, 우수한 자산을 보유한 투자자에게는 포지션 및 포지션 절감 시간을 최적화하는 데 도움이 될 수 있습니다.

전략 소스 코드
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-09 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Demo GPT - Bollinger Bands Strategy with Tightened Trailing Stops", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_value=0.1, slippage=3)

// Input settings
length = input.int(20, minval=1)
maType = input.string("SMA", "Basis MA Type", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"])
src = input(close, title="Source")
mult = 1.5 // Standard deviation multiplier set to 1.5
offset = input.int(0, "Offset", minval=-500, maxval=500)
atrMultiplier = input.float(1.0, title="ATR Multiplier for Trailing Stop", minval=0.1) // ATR multiplier for trailing stop

// Time range filters
start_date = input(timestamp("2018-01-01 00:00"), title="Start Date")
end_date = input(timestamp("2069-12-31 23:59"), title="End Date")
in_date_range = true

// Moving average function
ma(source, length, _type) =>
    switch _type
        "SMA" => ta.sma(source, length)
        "EMA" => ta.ema(source, length)
        "SMMA (RMA)" => ta.rma(source, length)
        "WMA" => ta.wma(source, length)
        "VWMA" => ta.vwma(source, length)

// Calculate Bollinger Bands
basis = ma(src, length, maType)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev

// ATR Calculation
atr = ta.atr(length) // Use ATR for trailing stop adjustments

// Plotting
plot(basis, "Basis", color=#2962FF, offset=offset)
p1 = plot(upper, "Upper", color=#F23645, offset=offset)
p2 = plot(lower, "Lower", color=#089981, offset=offset)
fill(p1, p2, title="Background", color=color.rgb(33, 150, 243, 95))

// Candle color detection
isGreen = close > open
isRed = close < open

// Flags for entry and exit conditions
var bool redTouchedLower = false
var float targetPrice = na
var float stopLossPrice = na
var float trailingStopPrice = na

if in_date_range
    // Entry Logic: First green candle after a red candle touches the lower band
    if close < lower and isRed
        redTouchedLower := true
    if redTouchedLower and isGreen
        strategy.entry("Long", strategy.long)
        targetPrice := close * 1.2       // Set the target price to 20% above the entry price
        stopLossPrice := close * 0.88   // Set the stop loss to 12% below the entry price
        trailingStopPrice := na         // Reset trailing stop on entry
        redTouchedLower := false

    // Exit Logic: Trailing stop after 20% price increase
    if strategy.position_size > 0 and not na(targetPrice) and close >= targetPrice
        if na(trailingStopPrice)
            trailingStopPrice := close - atr * atrMultiplier // Initialize trailing stop using ATR
        trailingStopPrice := math.max(trailingStopPrice, close - atr * atrMultiplier) // Tighten dynamically based on ATR

    // Exit if the price falls below the trailing stop after 20% increase
    if strategy.position_size > 0 and not na(trailingStopPrice) and close < trailingStopPrice
        strategy.close("Long", comment="Trailing Stop After 20% Increase")
        targetPrice := na // Reset the target price
        stopLossPrice := na // Reset the stop loss price
        trailingStopPrice := na // Reset trailing stop

    // Stop Loss: Exit if the price drops 12% below the entry price
    if strategy.position_size > 0 and not na(stopLossPrice) and close <= stopLossPrice
        strategy.close("Long", comment="Stop Loss Triggered")
        targetPrice := na // Reset the target price
        stopLossPrice := na // Reset the stop loss price
        trailingStopPrice := na // Reset trailing stop

    // Trailing Stop: Activate after touching the upper band
    if strategy.position_size > 0 and close >= upper and isGreen
        if na(trailingStopPrice)
            trailingStopPrice := close - atr * atrMultiplier // Initialize trailing stop using ATR
        trailingStopPrice := math.max(trailingStopPrice, close - atr * atrMultiplier) // Tighten dynamically based on ATR

    // Exit if the price falls below the trailing stop
    if strategy.position_size > 0 and not na(trailingStopPrice) and close < trailingStopPrice
        strategy.close("Long", comment="Trailing Stop Triggered")
        trailingStopPrice := na // Reset trailing stop
        targetPrice := na // Reset the target price
        stopLossPrice := na // Reset the stop loss price