PSAR 지표와 동적 Bollinger Bands를 결합한 고급 양적 거래 전략

BB PSAR SMA TP SL
생성 날짜: 2025-02-18 14:11:00 마지막으로 수정됨: 2025-02-18 14:11:00
복사: 0 클릭수: 355
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

PSAR 지표와 동적 Bollinger Bands를 결합한 고급 양적 거래 전략

개요

이것은 부린띠와 패러블라인 전환 지표 ((PSAR) 를 결합한 통합 거래 전략이며, 고정된 위험/수익 비율을 사용하여 거래를 관리한다. 이 전략은 주로 일일 거래 시간대에 운영되며, 가격의 부린띠 및 그래프 형태를 뚫고 거래 기회를 식별하고, 동시에 PSAR 지표를 사용하여 트렌드를 확인한다. 이 전략은 다이내믹 스톱 손실과 수익 목표 설정을 채택하고, 위험/수익 비율을 1:3으로 유지한다.

전략 원칙

다중 기술 지표를 사용하여 거래 신호를 확인하는 전략:

  1. 20주기의 브린 밴드를 주요 가격 변동 범위 지표로 사용
  2. 트렌드 확인 도구로 PSAR 지표 ((초기값 0.02, 최대값 0.2) 를 사용함
  3. 신호의 신뢰성을 보장하기 위해 실선 실체 비율 ((실체 길이/총 길이 ≥0.33) 을 계산합니다.
  4. 지정된 거래 시간 창 (GMT-5 7:30-16:00) 에서 거래를 실행
  5. 다수 입시 조건: 종식 가격 돌파구 및 ?? 실물 비율이 요구 사항을 충족
  6. 공허 입시 조건: 종전 가격이 하락 궤도를 돌파하고 ?? 실물 비율이 요구 사항을 충족

전략적 이점

  1. 다중 기술 지표와 결합하여 신호 신뢰성을 향상시킵니다.
  2. 고정된 리스크 수익률을 사용함 ((1:3)), 장기적으로 안정적인 수익을 유도함
  3. 시간적으로 필터링하여 유동성이 낮은 기간의 간섭을 방지합니다.
  4. 실체 비율 필터링을 사용하여 가짜 돌파구를 줄여줍니다.
  5. 동적 정지 및 수익 목표를 설정하여 시장의 변동에 적응하십시오.
  6. 명확하고 이해하기 쉽고 최적화할 수 있는 전략 논리

전략적 위험

  1. 높은 변동성 시장에서 미끄러짐이 발생할 수 있습니다.
  2. 일정한 리스크/이익 비율은 일부 수익 기회를 놓칠 수 있습니다.
  3. 시간 필터는 중요한 시장 기회를 놓칠 수 있습니다.
  4. 여러 지표로 인해 신호 지연이 발생할 수 있습니다.
  5. 불안한 시장에서 지속적인 손실이 발생할 수 있습니다.

전략 최적화 방향

  1. 다양한 시장 환경에 적응하기 위해 적응형 브린 벨트 주기를 도입
  2. 역동적인 개발의 위험과 이익 대비 설정 메커니즘
  3. 보조 확인으로 볼륨 표시기 추가
  4. 트렌드 추적 효과를 높이기 위해 PSAR 파라미터를 최적화합니다.
  5. 시장 변동율 필터에 가입하세요
  6. 더 똑똑한 시간 필터링을 개발하는 것

요약하다

이 전략은 브린밴드, PSAR 지표 및 그라프 분석을 통합하여 전체적인 거래 시스템을 구축한다. 이 전략의 핵심 장점은 다중 기술 지표의 연동과 엄격한 위험 관리이다. 일부 고유한 위험이 존재하지만, 제안된 최적화 방향은 전략의 안정성과 수익성을 더욱 향상시킬 수 있다. 이 전략은 특히 일간 거래 사용자에 적합하며 위험을 통제하면서 안정적인 수익을 얻을 수 있다.

전략 소스 코드
/*backtest
start: 2024-02-18 00:00:00
end: 2025-02-17 00:00:00
period: 2h
basePeriod: 2h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=6
strategy("Estrategia Bollinger con PSAR y TP Máximo/ Mínimo", overlay=true)

// Parámetros de las Bandas de Bollinger
bb_length = input.int(20, title="Periodo de Bandas de Bollinger", minval=1)
bb_stddev = input.float(2.0, title="Desviación Estándar", step=0.1)

// Parámetros del Parabolic SAR
psar_start = input.float(0.02, title="PSAR Factor Inicial", step=0.01)
psar_increment = input.float(0.02, title="PSAR Incremento", step=0.01)
psar_max = input.float(0.2, title="PSAR Máximo", step=0.01)

// Cálculo de Bandas de Bollinger
basis = ta.sma(close, bb_length)
upper_band = basis + bb_stddev * ta.stdev(close, bb_length)
lower_band = basis - bb_stddev * ta.stdev(close, bb_length)

// Cálculo del Parabolic SAR
psar = ta.sar(psar_start, psar_increment, psar_max)

// Cálculo del cuerpo de la vela
body_high = math.max(open, close)
body_low = math.min(open, close)
body_length = body_high - body_low
total_length = high - low
body_ratio = body_length / total_length

// Condiciones de Entrada
long_condition = close > upper_band and body_ratio >= 0.33
short_condition = close < lower_band and body_ratio >= 0.33

// Filtro de tiempo: Operar solo de 7:30 AM a 4:00 PM hora colombiana
start_time = timestamp("GMT-5", year, month, dayofmonth, 7, 30)
end_time = timestamp("GMT-5", year, month, dayofmonth, 16, 0)
time_condition = (time >= start_time) and (time <= end_time)

// Variables para mantener el TP máximo y mínimo
var float max_tp = na
var float min_tp = na
var float dynamic_stop = na

// Condiciones de Entrada y Salida
if (long_condition and time_condition)
    entry_price = close  // Precio de entrada
    stop_loss = low  // SL en el mínimo de la vela
    take_profit = entry_price + 3 * (entry_price - stop_loss)  // TP con relación 1:3
    strategy.entry("Compra", strategy.long)
    strategy.exit("Exit Compra", "Compra", stop=stop_loss, limit=take_profit)

    // Dibujar las etiquetas para SL y TP para la operación larga
    label.new(bar_index, stop_loss, text="SL: " + str.tostring(stop_loss), style=label.style_label_up, color=color.red, textcolor=color.white, size=size.small)
    label.new(bar_index, take_profit, text="TP: " + str.tostring(take_profit), style=label.style_label_down, color=color.green, textcolor=color.white, size=size.small)

if (short_condition and time_condition)
    entry_price = close  // Precio de entrada
    stop_loss = high  // SL en el máximo de la vela
    take_profit = entry_price - 3 * (stop_loss - entry_price)  // TP con relación 1:3
    strategy.entry("Venta", strategy.short)
    strategy.exit("Exit Venta", "Venta", stop=stop_loss, limit=take_profit)

    // Dibujar las etiquetas para SL y TP para la operación corta
    label.new(bar_index, stop_loss, text="SL: " + str.tostring(stop_loss), style=label.style_label_down, color=color.red, textcolor=color.white, size=size.small)
    label.new(bar_index, take_profit, text="TP: " + str.tostring(take_profit), style=label.style_label_up, color=color.green, textcolor=color.white, size=size.small)

// Dibujar Bandas de Bollinger
plot(upper_band, color=color.red, title="Banda Superior")
plot(lower_band, color=color.green, title="Banda Inferior")
plot(basis, color=color.blue, title="Media Base")

// Dibujar Parabolic SAR
plot(psar, style=plot.style_circles, color=color.orange, title="Parabolic SAR")