Donchian 채널 돌파 전략


생성 날짜: 2023-09-14 14:44:44 마지막으로 수정됨: 2023-09-14 14:44:44
복사: 0 클릭수: 766
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

전략 원칙

동치안 통로 돌파 전략은 동치안 통로에 기반한 트렌드 추적 전략이다. 이 전략은 다양한 주기에서 최고 가격과 최저 가격을 사용하여 다중 헤드 및 빈 헤드의 입점과 중지 지점을 결정한다.

전략의 입문 규칙은: 가격이 지정된 주기 (예: 20일) 의 최고 가격을 돌파할 때, 더 많이; 가격이 지정된 주기 (예: 10일) 의 최저 가격을 돌파할 때, 공백을 다.

EXIT 규칙은: 다중 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위

거래 품종이 BTCUSDT라고 가정하면, 다음과 같은 파라미터를 설정합니다.

  • 다중 입원주기: 20일
  • 다중자리 정지주기: 10일
  • 중간 경로 상해: 네
  • 비상장 입원 기간: 10일
  • 공백기 절감기: 20일
  • 중간 경로 상해: 네

그래서 입점과 중단 규칙은 다음과 같습니다.

  • 20일 최고치를 넘어서서 그 지점에서 상장
  • 다중 포지션 정지점은 10일 동안의 최고 가격과 최저 가격의 중간 지점입니다.
  • 10일 최저값을 넘으면 그 지점에서 공백점으로 입점합니다.
  • 20일 동안의 최고 가격과 최저 가격의 중간 지점

진입 및 중단 주기의 파라미터를 동적으로 조정하여 다른 시장 주기에 최적화하여 트렌드 상황에서 더 나은 수익을 얻을 수 있습니다.

전략적 이점

  • 트렌드 방향에 대한 통찰을 통해 강세를 파악할 수 있습니다.
  • 현재 가격에 가까운 스톱로스는 위험을 통제하는 데 도움이 됩니다.
  • 매개 변수 조정 유연성, 다른 주기에 최적화

전략적 위험

  • 브레이크 트레이드는 쉽게 조작될 수 있으며, 브레이크의 유효성을 결정하는 데는 신중해야 합니다.
  • 가격과 가까운 스톱포인트, 충격적인 상황에서는 손실을 중단할 확률이 높습니다.
  • 잘못된 매개 변수 설정으로 인해 너무 자주 출전하거나 적시에 손실을 막을 수 없습니다.

요약하다

동치안 통로 돌파 전략은 돌파를 통해 트렌드 방향을 판단하고, 스톱포인트는 통로 중점 또는 하향으로 설정하여 위험을 효과적으로 제어할 수 있다. 최적화 파라미터 설정을 통해 트렌드 상황에서 전략의 포획율을 높일 수 있다. 그러나 돌파의 효과 판단과 교섭을 피하기 위해 신중하게 사용해야 한다. 종합적으로, 이 전략은 중선 긴 트렌드 상황을 추적하는 데 적합하지만, 흔들림 상황에서 사용해서는 안 된다.

전략 소스 코드
/*backtest
start: 2023-08-14 00:00:00
end: 2023-09-13 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy("Donchian Channel Strategy", overlay=true, default_qty_type= strategy.percent_of_equity, initial_capital = 1000, default_qty_value = 20, commission_type=strategy.commission.percent, commission_value=0.036)

//Long optopns
buyPeriodEnter = input(10, "Channel Period for Long enter position")
buyPeriodExit = input(10, "Channel Period for Long exit position")
isMiddleBuy = input(true, "Is exit on Base Line? If 'no' - exit on bottom line")
takeProfitBuy = input(2.5, "Take Profit (%) for Long position")
isBuy = input(true, "Allow Long?")

//Short Options
sellPeriodEnter = input(20, "Channel Period for Short enter position")
sellPeriodExit = input(20, "Channel Period for Short exit position")
isMiddleSell = input(true, "Is exit on Base Line? If 'no' - exit on upper line")
takeProfitSell = input(2.5, "Take Profit (%) for Short position")
isSell = input(true, "Allow Short?")

// Test Start
startYear = input(2005, "Test Start Year")
startMonth = input(1, "Test Start Month")
startDay = input(1, "Test Start Day")
startTest = timestamp(startYear,startMonth,startDay,0,0)

//Test End
endYear = input(2050, "Test End Year")
endMonth = input(12, "Test End Month")
endDay = input(30, "Test End Day")
endTest = timestamp(endYear,endMonth,endDay,23,59)

timeRange = time > startTest and time < endTest ? true : false

// Long&Short Levels
BuyEnter = highest(buyPeriodEnter)
BuyExit = isMiddleBuy ? ((highest(buyPeriodExit) + lowest(buyPeriodExit)) / 2): lowest(buyPeriodExit)

SellEnter = lowest(sellPeriodEnter)
SellExit = isMiddleSell ? ((highest(sellPeriodExit) + lowest(sellPeriodExit)) / 2): highest(sellPeriodExit)

// Plot Data
plot(BuyEnter, style=plot.style_line, linewidth=2, color=color.blue, title="Buy Enter")
plot(BuyExit, style=plot.style_line, linewidth=1, color=color.blue, title="Buy Exit", transp=50)
plot(SellEnter, style=plot.style_line, linewidth=2, color=color.red, title="Sell Enter")
plot(SellExit, style=plot.style_line, linewidth=1, color=color.red, title="Sell Exit", transp=50)

// Calc Take Profits
TakeProfitBuy = 0.0
TakeProfitSell = 0.0
if strategy.position_size > 0
    TakeProfitBuy := strategy.position_avg_price*(1 + takeProfitBuy/100)
    
if strategy.position_size < 0
    TakeProfitSell := strategy.position_avg_price*(1 - takeProfitSell/100)

// Long Position    
if isBuy and timeRange
    strategy.entry("Long", strategy.long, stop = BuyEnter, when = strategy.position_size == 0) 
    
strategy.exit("Long Exit", "Long", stop=BuyExit, limit = TakeProfitBuy, when = strategy.position_size > 0)

// Short Position
if isSell and timeRange
    strategy.entry("Short", strategy.short, stop = SellEnter, when = strategy.position_size == 0) 
    
strategy.exit("Short Exit", "Short", stop=SellExit, limit = TakeProfitSell, when = strategy.position_size < 0)

// Close & Cancel when over End of the Test
if time > endTest
    strategy.close_all()
    strategy.cancel_all()