브레이크아웃 구조와 볼륨 확인 다중 조건 스마트 트레이딩 전략

BOS SMA ATR TP SL
생성 날짜: 2024-12-20 16:15:43 마지막으로 수정됨: 2024-12-20 16:15:43
복사: 0 클릭수: 442
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

브레이크아웃 구조와 볼륨 확인 다중 조건 스마트 트레이딩 전략

개요

이 전략은 거래의 신뢰성과 위험 제어 능력을 높이기 위해 연속적인 확인 횟수 요구 사항과 동적 스톱 로스 설정을 포함한 다중 조건 검증 메커니즘을 사용합니다.

전략 원칙

전략의 핵심 논리에는 다음과 같은 핵심 요소가 포함됩니다.

  1. 지정된 주기 내의 최고 가격과 최저 가격을 계산하여 구조적인 최고점과 최저점을 식별합니다.
  2. 이동 평균을 사용하여 거래량 기준을 계산하여 현재 거래량이 크게 증가했는지 판단합니다.
  3. 가격이 이전 고점을 넘어서 거래량이 증가하면 누적된 다중 확인
  4. 가격 하락과 거래량이 증가할 때 누적 공백 확인
  5. 거래 신호는 지정된 확인 횟수를 달성한 후에만 트레이드 신호를 니다.
  6. 창고가 된 후 백분율 기반의 스톱 스톱 가격

전략적 이점

  1. 다중 조건 검증 메커니즘이 거래 신호의 신뢰성을 높인다.
  2. 가짜 돌파구로 인한 잘못된 판단을 방지하기 위해 합성 거래량 지표
  3. 연속 확인 메커니즘을 사용하여, 동작 주파수를 낮추고, 승률을 높여라
  4. 다이내믹 스톱 스톱 손실 설정으로, 진입 가격에 따라 퇴출 위치를 자동으로 조정
  5. 명확한 전략 논리, 변수 조정성, 적응성

전략적 위험

  1. 파동 시장은 종종 가짜 돌파구가 발생하여 연속적인 손실을 초래할 수 있습니다.
  2. 이 경우, 주식 시장의 변동이 심할 경우, 스톱 파일이 적절하지 않을 수 있습니다.
  3. 확인 메커니즘으로 인해 입장이 지연되고, 최고의 가격을 놓칠 수 있습니다.
  4. 거래량 판단 기준이 고정되어 있어 시장의 변화에 잘 적응할 수 없다. 해결책:
  • 시장 변동률 지표, 동적 조정 매개 변수 도입
  • 트렌드 필터를 추가하여 위축 시장의 가짜 신호를 줄여줍니다.
  • 손해 차단 논리를 최적화하고 손해 차단 유연성을 향상시킵니다.
  • 맞춤형 교역량 값 계산 방법을 설계

전략 최적화 방향

  1. 이동 평균 시스템과 같은 추세를 판단하는 지표를 추가하여 추세 방향으로만 거래합니다.
  2. ATR 지표의 동적으로 조정되는 정지 거리를 도입하여 풍력 제어의 유연성을 향상시킵니다.
  3. 설계 변동률 자율적 거래량 하락 판단 메커니즘
  4. 시간 필터를 추가하여 위험 기간을 피하십시오.
  5. 인증 메커니즘을 최적화하여 신뢰성을 보장하면서 입학 시 효율성을 높입니다.

요약하다

이것은 기술분석의 고전 이론과 현대적인 양적 거래방법을 결합한 전략 시스템이다. 다중 조건 검증과 엄격한 위험 통제를 통해 전략은 더 나은 안정성과 신뢰성을 가지고 있다.

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

//@version=5
strategy("BOS and Volume Strategy with Confirmation", overlay=true)

// Parameters
swingLength = input.int(20, title="Swing Length", minval=1)
volumeMultiplier = input.float(1.1, title="Volume Multiplier", step=0.1)
volumeSMA_length = input.int(10, title="Volume SMA Length", minval=1)
takeProfitPercentage = input.float(0.02, title="Take Profit Percentage", step=0.01)
stopLossPercentage = input.float(0.15, title="Stop Loss Percentage", step=0.01)  // New parameter for stop loss
atrLength = input.int(14, title="ATR Length")
confirmationBars = input.int(2, title="Confirmation Bars", minval=1)

// Calculate Swing Highs and Lows
swingHigh = ta.highest(high, swingLength)[1]
swingLow = ta.lowest(low, swingLength)[1]

// Calculate Volume Moving Average
volumeSMA = ta.sma(volume, volumeSMA_length)
highVolume = volume > (volumeSMA * volumeMultiplier)

// Break of Structure Detection with Confirmation
var int bullishCount = 0
var int bearishCount = 0

if (close > swingHigh and highVolume)
    bullishCount := bullishCount + 1
    bearishCount := 0
else if (close < swingLow and highVolume)
    bearishCount := bearishCount + 1
    bullishCount := 0
else
    bullishCount := 0
    bearishCount := 0

bullishBOSConfirmed = (bullishCount >= confirmationBars)
bearishBOSConfirmed = (bearishCount >= confirmationBars)

// Entry and Exit Conditions
var float entryPrice = na  // Declare entryPrice as a variable

if (bullishBOSConfirmed and strategy.position_size <= 0)
    entryPrice := close  // Use ':=' for assignment
    strategy.entry("Long", strategy.long)

if (strategy.position_size > 0)
    // Calculate stop loss price
    stopLossPrice = entryPrice * (1 - stopLossPercentage)
    strategy.exit("Take Profit Long", from_entry="Long", limit=entryPrice * (1 + takeProfitPercentage), stop=stopLossPrice)

if (bearishBOSConfirmed and strategy.position_size >= 0)
    entryPrice := close  // Use ':=' for assignment
    strategy.entry("Short", strategy.short)

if (strategy.position_size < 0)
    // Calculate stop loss price
    stopLossPrice = entryPrice * (1 + stopLossPercentage)
    strategy.exit("Take Profit Short", from_entry="Short", limit=entryPrice * (1 - takeProfitPercentage), stop=stopLossPrice)

// Plot Swing Highs and Lows for Visualization
plot(swingHigh, title="Swing High", color=color.green, linewidth=1)
plot(swingLow, title="Swing Low", color=color.red, linewidth=1)