지지 및 저항 수준 돌파 및 백테스팅을 기반으로 한 다단계 정량적 추세 거래 전략

Pivot SR MA BREAKOUT RETEST Trend
생성 날짜: 2025-02-20 16:00:35 마지막으로 수정됨: 2025-02-20 16:00:35
복사: 2 클릭수: 377
avatar of ianzeng123 ianzeng123
2
집중하다
319
수행원

지지 및 저항 수준 돌파 및 백테스팅을 기반으로 한 다단계 정량적 추세 거래 전략 지지 및 저항 수준 돌파 및 백테스팅을 기반으로 한 다단계 정량적 추세 거래 전략

개요

이것은 지지를 저항점의 돌파와 재측정을 기반으로 한 양적 거래 전략이다. 전략은 중요한 가격의 지지점과 저항점을 식별하여 가격 돌파 이후의 재측정 확인 지점에 거래한다. 이 전략은 좌우로 돌아가는 바 수동 위치의 핵심 지점을 채택하고, 재측정 용량 차와 결합하여 가짜 돌파를 통과하여 거래의 정확성과 안정성을 향상시킨다.

전략 원칙

이 전략은 다음과 같은 핵심 논리를 포함하고 있습니다.

  1. 지정된 수의 K 선을 좌우로 돌아보며 중요한 지지 및 저항 피벗 지점을 식별합니다.
  2. 상태 변수를 설정하여 후보 지지 저항의 돌파구 및 재측정을 추적합니다.
  3. 새로운 피벗 포인트가 나타났을 때 후보지원 저항점을 업데이트합니다.
  4. 가격이 후보지원저항을 뚫고 재검토될 때 거래합니다.
    • 가격 하락 후 지지점 근처로 상승하면 더 많이 한다.
    • 가격이 저항을 뚫고 저항 부근으로 내려갈 때 공백
  5. 용량 변수를 사용하여 재측정 시의 가격 변동을 필터링하여 신호 품질을 향상시킵니다.

전략적 이점

  1. 고전적인 기술 분석 이론과 명확하고 이해하기 쉬운 논리
  2. 동적으로 중요한 지점을 인식하여 적응력이 강합니다.
  3. 뚫림과 재검토를 결합한 이중확인, 가짜 신호를 감소
  4. 용량 변수 필터링으로 잡음을 필터링하여 정확도를 향상시킵니다.
  5. 코드 구조가 명확하고, 유지보수 및 확장하기 쉽습니다.
  6. 여러 시간대와 품종에 적합하다

전략적 위험

  1. 불안한 시장에서 자주 거래하는 것은 손실로 이어질 수 있습니다.
  2. 가짜 신호를 뚫는 것은 여전히 가능한 일입니다.
  3. 매개변수 최적화에는 과적합의 위험이 있을 수 있습니다.
  4. 시장의 과도한 변동으로 인해 더 큰 손실이 발생할 수 있습니다.
  5. 거래 비용에 대한 영향

전략 최적화 방향

  1. 트렌드 필터를 추가하여 주 트렌드 방향으로만 거래합니다.
  2. 수량 확인 메커니즘에 가입
  3. 입학 시점을 최적화하고, 기술 지표 확인이 추가될 수 있습니다.
  4. 손해 방지 장치의 개량
  5. 포지션 관리 논리를 추가
  6. 다중 시간 주기 분석을 고려하십시오.

요약하다

이 전략은 고전적인 지지 저항 이론과 돌파 회수 논리를 통해 구성되어 있으며, 좋은 이론적 기반을 가지고 있다. 매개 변수 최적화 및 위험 통제를 통해 안정적인 거래 효과를 얻을 수 있다. 전략 코드 구조는 명확하고, 이해하기 쉽고 확장할 수 있으며, 강력한 실용적 가치를 가지고 있다. 실제 거래에서 시장 상황과 개인 위험 선호를 결합한 적절한 매개 변수 조정을 권장한다.

전략 소스 코드
/*backtest
start: 2024-02-21 00:00:00
end: 2025-02-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/

//@version=5
strategy("SR Breakout & Retest Strategy (4hr)", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10)

// ===== USER INPUTS =====
leftBars    = input.int(3, "Left Pivot Bars", minval=1)
rightBars   = input.int(3, "Right Pivot Bars", minval=1)
tolerance   = input.float(0.005, "Retest Tolerance (Fraction)", step=0.001)

// ===== PIVOT CALCULATION =====
pLow  = ta.pivotlow(low, leftBars, rightBars)
pHigh = ta.pivothigh(high, leftBars, rightBars)

// ===== STATE VARIABLES FOR CANDIDATE LEVELS =====
var float candidateSupport  = na
var bool  supportBroken     = false
var bool  supportRetested   = false

var float candidateResistance = na
var bool  resistanceBroken    = false
var bool  resistanceRetested  = false

// ===== UPDATE CANDIDATE LEVELS =====
if not na(pLow)
    candidateSupport := pLow
    supportBroken    := false
    supportRetested  := false

if not na(pHigh)
    candidateResistance := pHigh
    resistanceBroken    := false
    resistanceRetested  := false

// ===== CHECK FOR BREAKOUT & RETEST =====
// -- Support: Price breaks below candidate support and then retests it --
if not na(candidateSupport)
    if not supportBroken and low < candidateSupport
        supportBroken := true

    if supportBroken and not supportRetested and close >= candidateSupport and math.abs(low - candidateSupport) <= candidateSupport * tolerance
        supportRetested := true
        label.new(bar_index, candidateSupport, "Support Retest", 
                  style=label.style_label_up, color=color.green, textcolor=color.white, size=size.tiny)
        // Example trading logic: Enter a long position on support retest
        strategy.entry("Long_Support", strategy.long)

// -- Resistance: Price breaks above candidate resistance and then retests it --
if not na(candidateResistance)
    if not resistanceBroken and high > candidateResistance
        resistanceBroken := true

    if resistanceBroken and not resistanceRetested and close <= candidateResistance and math.abs(high - candidateResistance) <= candidateResistance * tolerance
        resistanceRetested := true
        label.new(bar_index, candidateResistance, "Resistance Retest", 
                  style=label.style_label_down, color=color.red, textcolor=color.white, size=size.tiny)
        // Example trading logic: Enter a short position on resistance retest
        strategy.entry("Short_Resistance", strategy.short)

// ===== PLOTTING =====
plot(pLow, title="Pivot Low (Support)", style=plot.style_circles, color=color.green, linewidth=2)
plot(pHigh, title="Pivot High (Resistance)", style=plot.style_circles, color=color.red, linewidth=2)