동치안 통로 돌파 전략은 동치안 통로에 기반한 트렌드 추적 전략이다. 이 전략은 다양한 주기에서 최고 가격과 최저 가격을 사용하여 다중 헤드 및 빈 헤드의 입점과 중지 지점을 결정한다.
전략의 입문 규칙은: 가격이 지정된 주기 (예: 20일) 의 최고 가격을 돌파할 때, 더 많이; 가격이 지정된 주기 (예: 10일) 의 최저 가격을 돌파할 때, 공백을 다.
EXIT 규칙은: 다중 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위
거래 품종이 BTCUSDT라고 가정하면, 다음과 같은 파라미터를 설정합니다.
그래서 입점과 중단 규칙은 다음과 같습니다.
진입 및 중단 주기의 파라미터를 동적으로 조정하여 다른 시장 주기에 최적화하여 트렌드 상황에서 더 나은 수익을 얻을 수 있습니다.
동치안 통로 돌파 전략은 돌파를 통해 트렌드 방향을 판단하고, 스톱포인트는 통로 중점 또는 하향으로 설정하여 위험을 효과적으로 제어할 수 있다. 최적화 파라미터 설정을 통해 트렌드 상황에서 전략의 포획율을 높일 수 있다. 그러나 돌파의 효과 판단과 교섭을 피하기 위해 신중하게 사용해야 한다. 종합적으로, 이 전략은 중선 긴 트렌드 상황을 추적하는 데 적합하지만, 흔들림 상황에서 사용해서는 안 된다.
/*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()