
이 전략의 핵심 아이디어는 돈치안 통로의 가격 돌파 상황에 따라 거래하는 것으로, 트렌드 추적 유형에 속한다. 그것은 가격 통로를 자동으로 식별하고, 가격 돌파구가 통로를 따라 있을 때 포지션을 열고, 가격이 통로 아래로 돌아와서 근처에 있거나 손해 막점으로 떨어질 때 평지 포지션을 한다. 이 전략은 중간 긴 선의 가격 트렌드를 포착하기 위해 고안되었으며, 주식 지수와 같은 금융 파생 상품의 알고리즘 거래에 적용된다.
이 전략은 돈치안 통로 지표에 기초하고 있으며, 돈치안 통로는 주어진 주기 동안의 최고 가격과 최저 가격으로 그려진 통로 영역입니다. 계산 방법은 다음과 같습니다:
오프 레일 = 근 n 사이클의 최고 가격 하위 궤도 = 근 n주기의 최저 가격
가격이 경로를 돌파할 때 다단 트렌드에 들어간다고 간주하고, 가격이 경로를 돌파할 때 공중 트렌드에 들어간다고 간주한다. 이 전략은 경로를 돌파하는 경우에만 고려한다.
거래 논리는 다음과 같습니다.
이 전략은 다음과 같은 장점을 가지고 있습니다.
이 전략에는 몇 가지 위험도 있습니다.
대응방법:
이 전략은 다음과 같은 부분에서 최적화될 수 있습니다.
이 전략은 전체적인 아이디어가 명확하고 이해하기 쉽고 구현되며, 성숙한 돈치안 통로 지표를 사용하여 트렌드 방향을 자동으로 식별한다. 동시에 구성은 유연하며, 실제 필요에 따라 조정할 수 있다.
/*backtest
start: 2022-12-07 00:00:00
end: 2023-12-07 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Giovanni_Trombetta
// Strategy to capture price channel breakouts
//@version=4
strategy("ChannelsBreakout", max_bars_back=50, overlay=true)
instrument = input(1, title = "Select 1: Stock/Forex, 2: Future")
money = input(10000, title = "Money for each trade")
backtest_start = input(2000, "Insert first year to backtest")
period = input(50, title = "Period in bars of Donchian Channel")
monetary_stoploss = input(1000, title = "Monetary Stop Loss")
quantity = if instrument != 1
1
else
int(money / close)
upBarrier = highest(high,period)
downBarrier = lowest(low,period)
up = highest(high,period / 4)
down = lowest(low,period / 4)
plot(upBarrier, color=color.green, linewidth=2)
plot(downBarrier, color=color.red, linewidth=2)
plot(up, color=color.lime, linewidth=1)
plot(down, color=color.orange, linewidth=2)
longCondition = crossover(close, upBarrier[1]) and year >= backtest_start
if (longCondition)
strategy.entry("Long", strategy.long, quantity, when = strategy.position_size == 0)
closeCondition = crossunder(close, down[1]) or down < down[1]
if (closeCondition)
strategy.close("Long", comment = "Trailing")
stop_level = strategy.position_avg_price - monetary_stoploss / strategy.position_size
strategy.exit("StopLoss", from_entry = "Long", stop = stop_level)
plot(stop_level, color=color.yellow, linewidth=2)
// l = label.new(bar_index, na,
// text="PineScript Code", color= color.lime, textcolor = color.white,
// style=label.style_labelup, yloc=yloc.belowbar, size=size.normal)
// label.delete(l[1])