돈치안 채널과 래리 윌리엄스 대형 무역 지수 전략

저자:차오장, 날짜: 2024-04-12 17:27:25
태그:

img

전반적인 설명

이 전략은 세 가지 지표 - 돈치안 채널, 래리 윌리엄스 대형 무역 지수 (LWTI) 및 볼륨 이동 평균 (Volume Moving Average) 를 결합하여 거래 신호를 생성합니다. 가격이 돈치안 채널의 상단역을 넘어서면 긴 포지션에 진입합니다. LWTI는 녹색이며 볼륨은 이동 평균보다 크습니다. 가격이 돈치안 채널의 하단역을 넘어서면 짧은 포지션에 진입합니다. LWTI는 빨간색이며 볼륨은 이동 평균보다 크습니다. 가격이 스톱 로스 (Stop Loss) 에 도달하거나 수익을 취하거나 가격이 돈치안 채널의 중단역으로 돌아옵니다. 같은 트렌드 방향으로 반복되는 입력을 방지하기 위해 전략은 거래 카운터를 사용하여 가격이 돈치안 채널의 중단역을 넘어서면만 새로운 입력을 허용합니다.

전략 원칙

  1. 돈치안 채널: 가격이 상단 범위를 넘어서면 긴 신호가 생성되고, 가격이 하단 범위를 넘어서면 짧은 신호가 생성됩니다.
  2. 래리 윌리엄스 대기업 지수: LWTI 색상이 녹색일 때만 장차가 허용되며 빨간색일 때만 단차가 허용됩니다.
  3. 부피: 현재 부피가 부피 이동 평균보다 높을 때만 항목이 허용됩니다.
  4. 트레이드 카운터: 같은 트렌드 방향으로 반복되는 입력을 방지하기 위해, 가격은 돈치안 채널의 중간 범위를 넘은 후에만 새로운 입력이 허용됩니다.
  5. 스톱 로스 및 트레이프 이윤: 입시시 스톱 로스 및 트레이프 이윤 거리는 ATR을 기반으로 계산되며, 트레이프 이윤 거리는 스톱 로스 거리를 리스크 리워드 비율로 곱한 것으로 계산됩니다.

전략적 장점

  1. 거래 신호를 확인하기 위해 여러 지표를 조합하면 잘못된 신호를 효과적으로 필터링하고 신호 품질을 향상시킬 수 있습니다.
  2. 동적 스톱 로스 및 영업 - 변동성에 따라 스톱 로스 및 영업 거리를 조정하면 전략이 시장 변화에 더 잘 적응 할 수 있습니다.
  3. 트레이드 카운터는 같은 트렌드에 대한 반복적인 입력을 방지하고 거래 빈도를 조절합니다.
  4. 리스크-리어워드 비율에 기반한 수익 - 미리 결정된 리스크-리어워드 비율에 기반한 수익 수준을 설정하면 수익 잠재력이 위험을 초과 할 수 있습니다.

전략 위험

  1. 매개 변수 위험 - 전략 성능은 다른 매개 변수 설정에 의해 크게 영향을 받으며, 다른 시장 특성과 시간 프레임에 따라 최적화를 요구합니다.
  2. 불안정한 시장 위험 - 불안정한 시장 조건에서, 빈번한 변동은 전략이 빈번하게 진입하고 퇴출하는 결과를 초래할 수 있습니다.
  3. 트렌드 리스크 - 트렌드가 지속되지 않으면 빈번한 진입 및 출입이 발생할 수 있으며 이로 인해 손실이 증가합니다.
  4. 블랙 스완 위험 - 극단적인 시장 조건에서 지표가 실패하여 전략 성과가 떨어질 수 있습니다.

전략 최적화 방향

  1. 가장 좋은 매개 변수 조합을 찾기 위해 다른 도구와 시간 프레임에 대한 매개 변수를 최적화합니다.
  2. 트렌드 필터링 조건, 예를 들어 이동 평균 또는 모멘텀 표시기를 사용하여 트렌드가 명확할 때만 포지션을 입력하여 불안정한 환경에서 거래 수를 줄입니다.
  3. 불안한 시장 조건에서 범위를 깨는 전략을 사용하는 것을 고려하십시오.
  4. 스톱 로스를 최적화하고 트레일링 스톱 또는 다른 방법을 도입하여 수익 논리를 취하십시오.
  5. 극심한 시장 상황에서는 고정 금전 관리 및 최대 유출 제한을 도입하는 것을 고려하십시오.

요약

돈치안 채널 및 래리 윌리엄스 대형 무역 지수 전략은 트렌드를 따르는 고전적인 거래 전략이다. 돈치안 채널을 사용하여 트렌드 방향을 캡처하고, LWTI, 볼륨 및 기타 지표를 사용하여 신호를 필터하고, 엄격한 리스크 통제를 통해 동적 스톱 로스 및 수익을 취한다. 전반적으로, 이는 안정적인 수익을 얻을 수 있는 잠재력을 가진 전략 프레임워크이다. 그러나, 전략이 매개 변수에 민감하고 불안정한 시장 조건에서 성능이 좋지 않다는 점에 유의해야 한다. 트렌딩 시장에서 사용이 권장된다. 실제 응용에서는, 거래 도구와 시장 특성에 기초한 매개 변수와 논리의 추가 최적화와 엄격한 돈 관리와 함께 좋은 안정적인 수익을 달성하는 것이 필요하다.


/*backtest
start: 2024-04-04 00:00:00
end: 2024-04-11 00:00:00
period: 1m
basePeriod: 1m
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/
// © DillonGrech
//
//This is a Donchian Channel Trading Strategy which was found through the 
//YouTube channel TradingLab. 
//
//This Strategy uses the Donchian Channel, Larry Williams Large Trade Index,
//and Volume with Moving Average indicators for long and short trades.
//
//Strategy will enter based off indicator entry conditions and will not
//re-enter a trade until the price crosses through the Donchian Channel
//basis line (to prevent re-entering trades in same trend). Strategy will
//exit at stop loss or take profit, or when price crosses donchian basis.
//
//The strategy has been coded by Dillon Grech as part of his YouTube channel
//and a detailed video can be found on his channel at:
//https://www.youtube.com/c/DillonGrech
//https://www.youtube.com/watch?v=5IFe2Vjf61Y
//Source code and template files can be found on his GitHub at:
//https://github.com/Dillon-Grech
//==============================================================================
//@version=5
strategy("Donchian Channel Strategy [DillonGrech]", overlay=true, margin_long=100, margin_short=100)

//==============================================================================
//DONCHIAN CHANNEL
//==============================================================================
//Allow user to select whether they would like to use indicator
Don_Input = input(true, title='Use Donchian Channel?', group = "Donchian Settings")

//Indicator
don_length = input.int(96, minval = 1, group = "Donchian Settings")
don_lower  = ta.lowest(don_length)
don_upper  = ta.highest(don_length)
don_basis  = math.avg(don_upper, don_lower)
plot(don_basis,     "Don Basis", color = #FF6D00)
u = plot(don_upper, "Don Upper", color = #2962FF)
l = plot(don_lower, "Don Lower", color = #2962FF)
fill(u, l, color = color.rgb(33, 150, 243, 95), title = "Background")

//Conditions - Enter trades when there is a cross of price and previous donchian channel value
Ind_1_L = Don_Input == false ? false : ta.crossover(close,don_upper[1])
Ind_1_S = Don_Input == false ? false : ta.crossunder(close,don_lower[1])

//==============================================================================
//LARRY WILLIAMS LARGE TRADE INDEX (LWTI) - LOXX
//==============================================================================
//Allow user to select whether they would like to use indicator
LWTI_Input = input(true, title='Use LWTI?', group = "LWTI Settings")

//Indicator
greencolor = #2DD204
redcolor = #D2042D 

variant(type, src, len) =>
    sig = 0.0
    if type == "SMA"
        sig := ta.sma(src, len) 
    else if type == "EMA"
        sig := ta.ema(src, len) 
    else if type == "WMA"
        sig := ta.wma(src, len)   
    else if type == "RMA"
        sig := ta.rma(src, len)  
    sig
    
LWTI_per = input.int(25, "Period", group = "LWTI Settings")
LWTI_smthit = input.bool(false, "Smooth LWPI?", group = "LWTI Settings")
LWTI_type = input.string("SMA", "Smoothing Type", options = ["EMA", "WMA", "RMA", "SMA"], group = "LWTI Settings")
LWTI_smthper = input.int(20, "Smoothing Period", group = "LWTI Settings")

LWTI_ma = ta.sma(close - nz(close[LWTI_per]), LWTI_per)
LWTI_atr = ta.atr(LWTI_per)
LWTI_out = LWTI_ma/LWTI_atr * 50 + 50
LWTI_out := LWTI_smthit ? variant(LWTI_type, LWTI_out, LWTI_smthper) : LWTI_out

LWTI_colorout = LWTI_out > 50 ? greencolor : redcolor

//Conditions - Enter on color of indicator
Ind_2_L = LWTI_Input == false ? true : LWTI_colorout == greencolor
Ind_2_S = LWTI_Input == false ? true : LWTI_colorout == redcolor

//==============================================================================
//VOLUME INDICATOR
//==============================================================================
//Allow user to select whether they would like to use indicator
Vol_Input = input(true, title='Use Volume?', group = "Volume Settings")

//Indicator
Vol_Ma_Period = input.int(30,"Volume MA Period", group = "Volume Settings")
Vol_Ma = ta.sma(volume,Vol_Ma_Period)

//Conditions - Enter when volume is greater than moving average
Ind_3_L = Vol_Input == false ? true : volume > Vol_Ma
Ind_3_S = Vol_Input == false ? true : volume > Vol_Ma

//==============================================================================
//DONCHIAN CHANNEL TRADE COUNTER
//==============================================================================
//Stores whether a trade has been taken, and resets when there is a cross of price and donchain basis
Trade_Counter = float(0)
Don_Basis_Cross = ta.cross(don_basis[1], close)
if strategy.position_size!=0
    Trade_Counter := 1
else if Don_Basis_Cross
    Trade_Counter := 0
else 
    Trade_Counter := Trade_Counter[1]

Plot_Trade_Counter = input.bool(false, "Plot Trade Position Counter?", group = "Plot Settings")
plotchar(Plot_Trade_Counter and Trade_Counter == 0 ? true : false, color = na, text = '0')
plotchar(Plot_Trade_Counter and Trade_Counter == 1 ? true : false, color = na, text = '1')

//==============================================================================
//ENTRY CONDITIONS
//==============================================================================
entry_long  = strategy.position_size<=0 and Ind_1_L and Ind_2_L and Ind_3_L and Trade_Counter[1] == 0
entry_short = strategy.position_size>=0 and Ind_1_S and Ind_2_S and Ind_3_S and Trade_Counter[1] == 0

if(entry_long)
    strategy.entry("Long Entry", strategy.long)
if(entry_short)
    strategy.entry("Short Entry", strategy.short)

//==============================================================================
// TAKE PROFIT AND STOP LOSS CONDITIONS
//==============================================================================
Stop_Input   = input(true, title='Use Stop Loss?', group = "Risk Settings")
Profit_Input = input(true, title='Use Take Profit?', group = "Risk Settings")
Profit_RR = input.float(2.0,"Risk Reward Profit Target", group = "Risk Settings")

//Store Price on new entry signal
Entry_Price = strategy.opentrades.entry_price(strategy.opentrades - 1)

//Store Donchain Channel Basis value on new entry signal
Entry_Don_Basis = float(0.0)
if strategy.position_size == 0 or entry_long or entry_short
    Entry_Don_Basis := don_basis
else
    Entry_Don_Basis := Entry_Don_Basis[1]

//Get stop loss distance
Stop_Distance = math.abs(Entry_Price - Entry_Don_Basis)*1.02

//For Long Trades, find the stop loss level
Stop_L = float(0.0)
if Stop_Input == true
    Stop_L := Entry_Price - Stop_Distance
else
    na

//For Long Trades, find the profit level
Profit_L = float(0.0)
if Profit_Input == true
    Profit_L := Entry_Price + Stop_Distance*Profit_RR
else
    na

//For Short Trades, find the stop loss level
Stop_S = float(0.0)
if Stop_Input == true
    Stop_S   := Entry_Price + Stop_Distance
else
    na

//For Short Trades, find the profit level
Profit_S = float(0.0)
if Profit_Input == true
    Profit_S := Entry_Price - Stop_Distance*Profit_RR
else
    na

//Plot profit and stop loss levels for long and short trades
plot(strategy.position_size > 0 ? Profit_L : na, color=color.lime, style=plot.style_linebr, linewidth=2)
plot(strategy.position_size > 0 ? Stop_L : na,   color=color.red,  style=plot.style_linebr, linewidth=2)
plot(strategy.position_size < 0 ? Profit_S : na, color=color.lime, style=plot.style_linebr, linewidth=2)
plot(strategy.position_size < 0 ? Stop_S : na,   color=color.red,  style=plot.style_linebr, linewidth=2)

//==============================================================================
//EXIT ORDERS
//==============================================================================
//Exit long trades
if Stop_Input
    strategy.exit(id = 'Exit Long', from_entry ='Long Entry', comment='Long Stop',  stop = Stop_L)

if Profit_Input
    strategy.exit(id = 'Exit Long', from_entry ='Long Entry', comment='Long Profit', limit = Profit_L)

//Exit short trades
if Stop_Input
    strategy.exit(id = 'Exit Short', from_entry ='Short Entry', comment='Short Stop', stop = Stop_S)

if Profit_Input
    strategy.exit(id = 'Exit Short', from_entry ='Short Entry', comment='Short Profit', limit = Profit_S)

//==============================================================================
//CLOSE ORDERS
//==============================================================================
exit_long  = close < don_basis
exit_short = close > don_basis

if(exit_long)
    strategy.close("Long Entry", comment='Long Close', qty_percent=100)
if(exit_short)
    strategy.close("Short Entry", comment='Short Close', qty_percent=100)

더 많은