Artikel ini menjelaskan secara rinci strategi perdagangan tren yang memanfaatkan tingkat dukungan dan resistensi dinamis.
I. Logika Strategi
Komponen utama dari strategi ini meliputi:
Menghitung tertinggi tertinggi dan terendah terendah selama periode tertentu untuk menentukan rentang perdagangan dinamis.
Perhitungan indikator ATR dan pengaturan band atas/bawah sebagai zona stop loss dinamis.
Menarik dukungan/resistensi dinamis pada lereng tetap ketika harga keluar dari kisaran perdagangan.
Menghasilkan sinyal perdagangan ketika harga melewati level support/resistance dinamis.
Dengan mensintesis zona support/resistance dinamis menggunakan berbagai indikator, perdagangan hanya dilakukan pada breakout untuk menyaring kebisingan yang tidak perlu. Zona stop loss juga menyesuaikan secara dinamis dengan perubahan pasar.
II. Keuntungan dari Strategi
Keuntungan terbesarnya terletak pada zona dinamis yang dibentuk oleh beberapa indikator, yang dapat dengan cepat mendeteksi perubahan tren.
Manfaat lain adalah zona stop loss bergaris, yang mengurangi kemungkinan stop yang dipukul.
Akhirnya, support/resistance miring sederhana dan mudah diterapkan.
III. Potensi Risiko
Namun, risiko potensial berikut juga harus dipertimbangkan:
Pertama, tingkat dinamis dapat menunda pergerakan harga dan menjadi tidak sah.
Kedua, zona stop loss yang terlalu luas dapat menyebabkan kerugian besar.
Akhirnya, penyesuaian parameter yang tidak tepat dapat menyebabkan kinerja strategi yang buruk.
IV. Ringkasan
Secara singkat, artikel ini telah menjelaskan strategi trend following menggunakan beberapa indikator dinamis untuk mengidentifikasi zona support dan resistance. Hal ini dapat secara efektif menyaring kebisingan dan mendeteksi tren. Namun risiko seperti indikator lag dan overwide stop harus dicegah. Secara keseluruhan, ini memberikan pendekatan yang wajar untuk memanfaatkan support dan resistance dinamis.
/*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")