이 글은 동적 지원 저항을 이용한 트렌드 거래를 하는 양적 전략에 대해 자세히 설명한다. 이 전략은 다중 지표의 동적 지원 저항을 사용하여 가격 트렌드를 포착한다.
1 전략
이 전략의 주요 구성 요소는 다음과 같습니다.
특정 주기 동안의 최고 가격과 최저 가격을 계산하고 동적인 다공간 통로를 설정합니다.
ATR 지수를 계산하고 동적 정지 지점으로 상하 궤도를 설정합니다.
채널을 통과할 때 동적인 지지와 저항을 일정한 기울기로 그리는 방법
동적 지원 저항을 통과하면 거래 신호가 형성됩니다.
종합 다중 지표는 역동적인 지지 저항대를 설정하고, 부득이한 잡음 신호를 제거하기 위해 단지 범위를 돌파할 때만 거래합니다. 동시에, 정지 지점은 시장 변화에 대응하기 위해 동적으로 조정됩니다.
2 전략적 장점
이 전략의 가장 큰 장점은 여러 가지 동적 지표가 지원 저항을 설정하는 데 있습니다. 이것은 가격 추세의 변화를 유연하고 효과적으로 식별 할 수 있습니다.
또 다른 장점은, 막힘이 뚫리는 확률을 줄일 수 있는, 끈 모양의 막힘 구역이다.
마지막으로, 기울기가 저항을 지탱하는 것을 그리는 방법은 간단하고 직접적이며, 구현하기 쉽다.
그러나 우리는 다음과 같은 잠재적인 위험도 고려해야 합니다.
첫째, 동적 지원 저항이 가격 변화에 따라 지연되어 무효화 될 수 있습니다.
두 번째, 너무 넓은 정지구역은 더 큰 손실을 초래할 수 있습니다.
마지막으로, 잘못된 변수 설정으로 인해 정책이 제대로 작동하지 않을 수 있습니다.
네 가지 내용
이 글은 역동적 다중 지표를 사용하여 지지 저항을 식별하는 트렌드 추적 전략을 자세히 소개한다. 그것은 효과적으로 잡음을 필터링하고, 트렌드를 식별할 수 있다. 그러나 우리는 지표 지연과 상쇄 과폭 등의 위험을 예방하기도 한다. 전체적으로, 이 전략은 역동적 지지 저항을 합리적으로 활용하는 사고 방식을 제공한다.
/*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"}]
*/
// This is a strategy that draws a trend line in the form of a slope whenever the high point and low point are updated.
// The upper slope serves as a resistance line, and the lower slope serves as a support line.
// Buy when the [close] of the candle crosses the slope
//@version=5
strategy("Donchian Trendline - Support Resistance Slope [UhoKang]", shorttitle="Donchian Trendline", overlay=true, initial_capital=1000000,default_qty_type=strategy.percent_of_equity,default_qty_value=100,commission_value=0.075, slippage=3, process_orders_on_close=true)
///////////////////////////////////// Time ///////////////////////////////////////////////////////////////////////////////
startYear = input.int(2019, 'Start-Year', confirm=false, inline='1')
startMonth = input.int(1, 'Month', confirm=false, inline='1')
startDay = input.int(1, 'Day', confirm=false, inline='1')
finishYear = input.int(2099, 'End-Year', confirm=false, inline='2')
finishMonth = input.int(1, 'Month', confirm=false, inline='2')
finishDay = input.int(1, 'Day', confirm=false, inline='2')
startTime = timestamp(startYear, startMonth, startDay)
finishTime = timestamp(finishYear, finishMonth, finishDay)
testPeriod = true
//////////////////////// ATR BAND ///////////////////////////////////////////////////////////////////////////////////////////
// Inputs
atrPeriod = input.int(title = "ATR Period", defval = 14, minval = 1)
atrBandUpper = input(title = "Source Upper", defval = close)
atrBandLower = input(title = "Source Lower", defval = close)
atrMultiplierUpper = input.int(title = "ATR Multiplier Upper", defval = 1)
atrMultiplierLower = input.int(title = "ATR Multiplier Lower", defval = 1)
// ATR ///////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------------
atr = ta.atr(atrPeriod)
atrBBUpper = atrBandUpper + (atr * atrMultiplierUpper)
atrBBLower = atrBandLower - (atr * atrMultiplierLower)
/////////////////////////// Big Candle ///////////////////////////////////////////////
//------------------------------------------------------------------------------------
candle_size = close>=open ? close-open : open-close
candle_grade_guide = atrBBUpper - atrBBLower
candle_grade = candle_size > candle_grade_guide ? 3 : candle_size > candle_grade_guide/2 ? 2 : 1
candle_grade_color = candle_grade == 3 ? color.new(color.black, 0) : candle_grade == 2 ? color.new(color.purple, 0) : na
barcolor(candle_grade_color, title = "Long candle")
///////////////////////////////////// Donchian ///////////////////////////////////////
//------------------------------------------------------------------------------------
donchian_length = input(60)
donchian_top = ta.highest(high, donchian_length)
donchian_bot = ta.lowest(low, donchian_length)
donchian_mid = (donchian_top + donchian_bot) / 2
plot_donchian_top = plot(donchian_top, color=color.new(color.green, 90), title = "Donchian Top")
plot_donchian_bot = plot(donchian_bot, color=color.new(color.red, 90), title = "Donchian Bottom")
plot_donchian_mid = plot(donchian_mid, color=color.new(color.orange, 0), title = "Donchian Middle")
fill(plot_donchian_top, plot_donchian_mid, color=color.new(color.green, 95), title = "Donchian Upper")
fill(plot_donchian_bot, plot_donchian_mid, color=color.new(color.red, 95), title = "Donchian Lower")
///////////////////////////// Trendline //////////////////////////////////////////////////
//------------------------------------------------------------------------------------
donchian_longTr = false
donchian_shortTr = false
var atrLongHeight = 0.0
var atrShortHeight = 0.0
if high > donchian_top[1]
donchian_longTr := true
atrLongHeight := atrBBUpper[1] - atrBBLower[1]
if low < donchian_bot[1]
donchian_shortTr := true
atrShortHeight := atrBBUpper[1] - atrBBLower[1]
donchian_Tr_color = donchian_longTr ? color.new(color.green,70) : donchian_shortTr ? color.new(color.red, 70) : na
//////////////////////// Set var //////////////////////////////////////////////
//------------------------------------------------------------------------------------
slope_mult = input.float(0.03, step=0.01, title = "Slope x")
var ph_M_Avg = 0.0 //slope avg high
var pl_M_Avg = 0.0 //slope avg low
var ph_M_Line = 0.0 //slope high
var pl_M_Line = 0.0 //slope low
ph_M = donchian_longTr[1]==true and high<donchian_top[1] ? high[1] : na
pl_M = donchian_shortTr[1]==true and low>donchian_bot[1] ? low[1] : na
plot(ph_M,color=color.blue, style = plot.style_linebr, linewidth = 3, offset = -1, title = "Pivot High")
plot(pl_M,color=color.blue, style = plot.style_linebr, linewidth = 3, offset = -1, title = "Pivot Low")
///////////////////////////////////////// Calc trendline /////////////////////////////
//------------------------------------------------------------------------------------
mirror_mode = input.bool(false , title = "Mirror Line")
ph_M_Avg := atrLongHeight * slope_mult
pl_M_Avg := atrShortHeight * slope_mult
// Calc slope
if mirror_mode
if ph_M
ph_M_Line := ph_M
pl_M_Line := donchian_mid[1]
else if pl_M
pl_M_Line := pl_M
ph_M_Line := donchian_mid[1]
else if ph_M_Line
ph_M_Line := ph_M_Line[1] - ph_M_Avg
pl_M_Line := pl_M_Line[1] + pl_M_Avg
else
if ph_M
ph_M_Line := ph_M
else if ph_M_Line
ph_M_Line := ph_M_Line[1] - ph_M_Avg
if pl_M
pl_M_Line := pl_M
else if pl_M_Line
pl_M_Line := pl_M_Line[1] + pl_M_Avg
// Delete trendline
if donchian_bot[1] > ph_M_Line
ph_M_Line := na
if donchian_top[1] < pl_M_Line
pl_M_Line := na
// Draw trendline
plot(ph_M_Line, color=color.new(color.green,20), style = plot.style_circles, linewidth = 1, title = "Trendline Top")
plot(pl_M_Line, color=color.new(color.maroon,20), style = plot.style_circles, linewidth = 1, title = "Trendline Bottom")
// Trade
ph_longTr = false
ph_longExitTr = false
ph_shortTr = false
ph_shortExitTr = false
//-----------------------------------------------------------------------------}
check_short_mode = input.bool(true, title= "Short Mode On")
if ta.crossover(close, ph_M_Line)
ph_longTr := true
else if ta.crossunder(close,pl_M_Line) or ta.crossunder(close, donchian_mid[1])
ph_longExitTr := true
if ta.crossunder(close, pl_M_Line)
ph_shortTr := true
else if ta.crossover(close,ph_M_Line) or ta.crossover(close, donchian_mid[1])
ph_shortExitTr := true
ph_Tr_color = ph_longTr ? color.new(color.green,80) : ph_shortTr ? color.new(color.red,80) : na
bgcolor(ph_Tr_color, title = "Break Slope")
if ph_longTr and testPeriod
strategy.entry("L", strategy.long)
else if ph_longExitTr
strategy.close("L")
if ph_shortTr and testPeriod and check_short_mode
strategy.entry("S", strategy.short)
else if ph_shortExitTr
strategy.close("S")