돈치안 채널 탈출 전략

저자:차오장, 날짜: 2023-09-14 14:44:44
태그:

전략 논리

돈치안 채널 브레이크아웃 전략은 돈치안 채널에 기반한 트렌드 다음 전략이다. 그것은 긴 포지션과 짧은 포지션의 진입 및 스톱 손실 지점을 결정하기 위해 지정된 기간 동안 가장 높은 고도와 가장 낮은 하위를 사용합니다.

진입 규칙은: 가격이 룩백 기간 동안 가장 높은 최고치를 넘을 때 (예를 들어 20 일) 길게 가고, 가격이 다른 룩백 기간 동안 가장 낮은 최저치를 넘을 때 짧게 간다 (예를 들어 10 일).

EXIT 규칙은 다음과 같습니다: 장 포지션은 채널의 중간에 또는 하단에 중지됩니다. 단점은 중간에 또는 상단에 중단됩니다. 중간에 있는 밴드는 지정된 기간 (예: 10 일) 동안 가장 높은 최고와 가장 낮은 최저의 평균입니다.

예를 들어, BTCUSDT를 다음과 같은 매개 변수로 거래합니다.

  • 장시간 검색 기간: 20일
  • 롱 스톱 로스 뷰백 기간: 10일
  • 중단역에서 손해를 멈추기: 네
  • 짧은 입력 검색 기간: 10 일
  • 단기 스톱 로스 리보크 기간: 20일
  • 중단역에서 손해를 멈추기: 네

출입 및 정지 규칙은 다음과 같습니다.

  • 가격이 20일 최고치를 넘을 때 장거리
  • 10일 최고치와 최저치의 중간 지점에서의 긴 스톱 로스
  • 가격이 10일 최저치를 넘어갈 때 단축
  • 20일 최고치와 최저치의 중간 지점에서의 단기 스톱 로스

역시기를 역동적으로 조정함으로써 전략은 시장 주기에 걸쳐 최적화되어 더 나은 수익/위험을 가진 트렌드를 포착 할 수 있습니다.

장점

  • 브레이크오웃은 트렌드 방향을 일찍 파악할 수 있습니다.
  • 가격에 가까운 손실을 막는 것은 위험을 관리하는 데 도움이 됩니다.
  • 유연 한 매개 변수 는 다른 주기에 최적화 할 수 있습니다.

위험성

  • 발작은 윙사 (wipssaws) 에 유연합니다. 유효성을 확인해야 합니다.
  • 불안한 시장에서 흔들림에 민감한 중지 손실을 닫으십시오.
  • 매개 변수 조정이 제대로 되지 않으면 거래가 너무 많거나 중지가 충분하지 않을 수 있습니다.

요약

돈치안 채널 브레이크아웃은 트렌드를 식별하기 위해 브레이크아웃을 사용하며, 채널 중점 / 밴드는 위험을 제어하기 위해 중지됩니다. 룩백 기간을 최적화하면 강력한 움직임에서 트렌드 캡처를 향상시킬 수 있습니다. 그러나 브레이크아웃 유효성과 쉐이크아웃에 대한 주의가 필요합니다. 전반적으로이 전략은 중장기 트렌드 거래에 적합하지만 불안정한 시장에서 어려움을 겪을 수 있습니다.


/*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()


더 많은