도치안 채널 트렌드 전략

저자:차오장, 날짜: 2024-01-22 12:30:05
태그:

img

전반적인 설명

돈치안 채널 트렌드 추적 전략은 돈치안 채널 지표에 기반한 트렌드 추적 전략이다. 가격 트렌드를 식별하고 가격이 채널을 벗어날 때 거래 신호를 생성하기 위해 다양한 길이의 돈치안 채널을 사용합니다.

이 전략의 주요 아이디어는 주요 트렌드 방향을 결정하기 위해 장기 기간 도 채널과 엔트리 및 스톱 로스 신호로 단기 기간 도 채널을 사용하는 것입니다. 시장의 단기 변동에 의해 오해받지 않고 중장기 가격 추세를 파악하는 것을 목표로합니다.

전략 논리

  1. 돈치안 채널을 구축하기 위해 장기간 (예: 50 일) 동안 가장 높은 폐쇄 가격과 가장 낮은 폐쇄 가격을 계산합니다. 상단보다 높은 파열은 상승 추세를 나타내고, 하단보다 낮은 파열은 하향 추세를 나타냅니다. 이것은 주요 트렌드 방향을 결정합니다.

  2. 최대의 종료 가격과 최저 종료 가격 짧은 기간 (예: 20 일) 을 입력 및 중지 손실의 기준으로 사용하십시오. 가격이 긴 기간 채널을 깨는 경우, 종료 가격도 짧은 기간 채널을 깨는 경우, 그에 따라 긴 / 짧은 위치를 취합니다.

  3. 긴 포지션을 보유 할 때, 가격이 단기 상단역 아래로 떨어지면, 손실로 중지하십시오. 짧은 포지션을 보유 할 때, 가격이 단기 상단역 위에 넘으면, 손실로 중지하십시오.

  4. 스톱 로스는 N 곱하기 ATR로 설정됩니다. 이것은 시장 변동성에 따라 자동으로 조정되며 스톱 로스가 발생할 확률이 낮습니다.

  5. 거래 세션이 끝나기 전에 포지션을 닫거나 스톱 로스를 달성할 때까지 포지션을 보유할 수 있는 옵션이 있습니다. 이것은 입력 매개 변수에 의해 제어됩니다.

이 전략은 트렌드 식별과 수익 스톱 로스 모두를 고려합니다. 위험 통제를 동시에 가격 트렌드를 포착 할 수 있습니다. 중장기 거래에 적합합니다.

이점 분석

  1. 단기 시장 소음으로 방해받지 않고 중장기 동향을 효과적으로 식별합니다.

  2. 자동 스톱 로스 메커니즘 거래 손실 당 제한

  3. ATR 기반의 스톱 로스는 시장 변동성에 따라 스톱 로스 거리를 조정하여 스톱 로스가 발생할 확률을 낮춰줍니다.

  4. 거래에서 위험을 관리할 수 없을 때 자동으로 포지션을 닫습니다.

  5. 단순하고 명확한 전략 논리, 이해하기 쉬운

위험 분석

  1. 트렌드가 없는 시장에서 전략은 더 많은 거래를 생성하여 거래 비용과 손실 가능성을 증가시킬 수 있습니다.

  2. 스톱 로스 메커니즘이 있음에도 불구하고 변동적인 조건에서의 가격 격차는 스톱 로스 포인트를 직접 침투하여 큰 손실을 유발할 수 있습니다.

  3. ATR 계산은 역사적인 데이터에만 기초하고 있으며 미래의 가격 움직임과 변동성을 정확하게 예측할 수 없습니다. 실제 정지 거리는 너무 넓거나 너무 좁을 수 있습니다.

  4. 스톱 로스 오더는 라이브 트레이딩에서 항상 채우지 못할 수 있습니다. 손실을 유발하는 극심한 변동성 조건에서 건너뛰어질 수 있습니다.

최적화 방향

  1. 트렌드 식별 성능을 최적화하기 위해 돈치안 채널 매개 변수를 조정합니다.

  2. MACD, KDJ와 같은 다른 지표를 통합하여 거래 신호를 확인하고 전략 안정성을 향상시킵니다.

  3. 가격과 함께 스톱 로스 포인트를 이동하기 위해 후속 스톱 로스를 추가하여 손실을 더 제한합니다.

  4. 최적의 전체 결과를 찾기 위해 다른 유지 기간의 영향을 테스트합니다.

  5. 동적으로 위치 크기를 조정하고 트렌드 조건에서 포지션을 확대하는 것을 고려하십시오.

요약

돈치안 채널 트렌드 다음 전략은 트렌드 식별과 리스크 통제를 통합합니다. 이 전략은 스톱 로스 메커니즘으로 꼬리 리스크를 제어하는 동시에 트렌드를 식별함으로써 과도한 수익을 창출하는 것을 목표로합니다. 이 전략은 중장기 가격 트렌드를 식별하고 포착하는 데 적합합니다. 매개 변수 최적화 및 메커니즘 향상으로 안정적인 긍정적 결과를 얻을 수 있습니다.


/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy(title="Donchian", overlay=true, calc_on_every_tick=true)

// =============================================================================
// VARIABLES
// =============================================================================

donch_string = input.string(title="Lenght", options = ['20/10','50/20', '50/50', '20/20', '100/100'], defval='20/10')
permit_long  = input.bool(title = 'Permit long', defval = true)
permit_short  = input.bool(title = 'Permit short', defval = true)
risk_percent = input.float(title="Position Risk %", defval=0.5, step=0.25)
stopOffset = input.float(title="ATR mult", defval=2.0, step=0.5)
atrLen = input.int(title="ATR Length", defval=20)
close_in_end  = input.bool(title = 'Close in end', defval = true)
permit_stop  = input.bool(title = 'Permit stop', defval = true)


// =============================================================================
// CALCULATIONS
// =============================================================================

donch_len_big = 
 donch_string == '50/20' ? 50 : 
 donch_string == '50/50' ? 50 : 
 donch_string == '20/20' ? 20 : 
 donch_string == '20/10' ? 20 : 
 donch_string == '100/100' ? 100 : 
 na
donch_len_small = 
 donch_string == '50/20' ? 20 : 
 donch_string == '50/50' ? 50 : 
 donch_string == '20/20' ? 20 : 
 donch_string == '20/10' ? 10 : 
 donch_string == '100/100' ? 100 : 
 na

big_maxclose = ta.highest(close, donch_len_big)
big_minclose = ta.lowest(close, donch_len_big)

small_maxclose = ta.highest(close, donch_len_small)
small_minclose = ta.lowest(close, donch_len_small)

atrValue = ta.atr(atrLen)[1]

tradeWindow  = true

// =============================================================================
// NOTOPEN QTY
// =============================================================================

risk_usd     = (risk_percent / 100) * strategy.equity
atr_currency = (atrValue * syminfo.pointvalue)
notopen_qty  = risk_usd / (stopOffset * atr_currency)

// =============================================================================
// LONG STOP
// =============================================================================

long_stop_price = 0.0
long_stop_price := 
 strategy.position_size > 0 and na(long_stop_price[1]) ? strategy.position_avg_price - stopOffset * atrValue : 
 strategy.position_size > 0 and strategy.openprofit > risk_usd ? strategy.position_avg_price:
 strategy.position_size > 0 ? long_stop_price[1] : 
 na

// =============================================================================
// SHORT STOP
// =============================================================================

short_stop_price = 0.0
short_stop_price := 
 strategy.position_size < 0 and na(short_stop_price[1]) ? strategy.position_avg_price + stopOffset * atrValue : 
 strategy.position_size < 0 and strategy.openprofit > risk_usd ? strategy.position_avg_price :
 strategy.position_size < 0 ? short_stop_price[1] : 
 na

// =============================================================================
// PLOT BG VERTICAL COLOR
// =============================================================================

cross_up = strategy.position_size <= 0 and close == big_maxclose and close >= syminfo.mintick and tradeWindow and permit_long
cross_dn =  strategy.position_size >= 0 and close == big_minclose and close >= syminfo.mintick and tradeWindow and permit_short
bg_color = cross_up ? color.green : cross_dn ? color.red : na
bg_color := color.new(bg_color, 70)
bgcolor(bg_color)

// =============================================================================
// PLOT HORIZONTAL LINES
// =============================================================================

s1 = cross_up ? na : cross_dn ? na : strategy.position_size != 0 ? strategy.position_avg_price : na
s2 = cross_up ? na : cross_dn ? na : strategy.position_size > 0 ? small_minclose : strategy.position_size < 0 ? small_maxclose : na
s3 = cross_up ? na : cross_dn ? na : not permit_stop ? na : 
 strategy.position_size > 0 ? long_stop_price : strategy.position_size < 0 ? short_stop_price : na

plot(series=big_maxclose, style=plot.style_linebr, color=color.black, linewidth=1, title="Donch Big Maxclose Black")
plot(series=big_minclose, style=plot.style_linebr, color=color.black, linewidth=1, title="Donch Big Minclose Black")

plot(series=s1, style=plot.style_linebr, color=color.yellow, linewidth=2, title="Entry Yellow")
plot(series=s2, style=plot.style_linebr, color=color.red, linewidth=1, title="Donch Small Red")
plot(series=s3, style=plot.style_linebr, color=color.fuchsia, linewidth=2, title="Stop Fuchsia")

// =============================================================================
// ENTRY ORDERS
// =============================================================================

if strategy.position_size <= 0 and close == big_maxclose and close >= syminfo.mintick and tradeWindow and permit_long
    strategy.entry("Long", strategy.long, qty=notopen_qty)

if (strategy.position_size >= 0) and close == big_minclose and close >= syminfo.mintick and tradeWindow and permit_short
    strategy.entry("Short", strategy.short, qty=notopen_qty)

// =============================================================================
// EXIT ORDERS
// =============================================================================

if strategy.position_size > 0 and permit_stop
    strategy.exit(id="Stop", from_entry="Long", stop=long_stop_price)

if strategy.position_size < 0 and permit_stop
    strategy.exit(id="Stop", from_entry="Short", stop=short_stop_price)

// ==========

if strategy.position_size > 0 and close == small_minclose and not barstate.islast
    strategy.close(id="Long", comment='Donch')

if strategy.position_size < 0 and close == small_maxclose and not barstate.islast
    strategy.close(id="Short", comment='Donch')

// ==========

if close_in_end
    if not tradeWindow
        strategy.close_all(comment='In end')

// =============================================================================
// END
// =============================================================================

더 많은