Chiến lược đẩy lùi động lực

Tác giả:ChaoZhang, Ngày: 2024-01-26 11:07:47
Tags:

img

Tổng quan

Chiến lược Pullback Momentum là một chiến lược giao dịch trung hạn kết hợp các đường trung bình động và các mô hình nến để xác định các cơ hội giao dịch bằng cách phát hiện sự phá vỡ và rút lui. Nó phù hợp với giao dịch các sản phẩm tài chính có đòn bẩy cao như tùy chọn và tương lai.

Chiến lược logic

Điểm mấu chốt của chiến lược này dựa trên đường trung bình di chuyển đơn giản 5 ngày. Khi giá sắp vượt qua đường trung bình này, nó sẽ tạo thành một nến cao hoặc thấp, báo hiệu một cơ hội dài hoặc ngắn tiềm năng.

Khi giá phá vỡ trên MA 5 ngày và đóng cửa, mức cao trước đó của nến khoảng cách là mức dừng lỗ. Mục tiêu lợi nhuận được thiết lập bằng cách trừ một phạm vi khôi phục nhất định từ mức thấp, nhân tỷ lệ rủi ro-lợi nhuận mong muốn. Tương tự đối với việc phá vỡ giảm, mức thấp trước đó của nến khoảng cách là mức dừng lỗ, trong khi mức lợi nhuận được lấy là trên mức cao cộng với phạm vi khôi phục được tính theo tỷ lệ rủi ro-lợi nhuận.

Một bộ lọc tùy chọn được cung cấp khi hiện tại nến đóng nên thấp hơn hoặc cao hơn một chút so với nến khoảng cách đóng để xác nhận thêm, tránh tín hiệu sai.

Phân tích lợi thế

  • Logic chiến lược rõ ràng và đơn giản, dễ hiểu và thực hiện
  • Xác định xu hướng và giảm giá bằng cách sử dụng đường trung bình động
  • Thời gian giao dịch chính xác hơn kết hợp các mô hình nến
  • Khớp rủi ro và phần thưởng, phù hợp với giao dịch thận trọng
  • Các tham số có thể điều chỉnh cho các sản phẩm và khung thời gian khác nhau
  • Bộ lọc tùy chọn tránh một số tín hiệu sai

Phân tích rủi ro

  • Rủi ro phân tích kỹ thuật thông thường như bị bắt trong xu hướng, dừng chạy qua
  • Bản chất chậm trễ của đường trung bình động có thể bỏ lỡ sự đảo ngược nhanh chóng
  • Có nhiều tín hiệu sai hơn trong các thị trường giới hạn phạm vi
  • Giao dịch quá mức do điều chỉnh tham số kém

Rủi ro có thể được giảm bằng cách dừng lỗ hợp lý, kích thước vị trí, giao dịch ít thường xuyên hơn v.v. Kết hợp các chỉ số khác để lọc tín hiệu cũng là một lựa chọn.

Hướng dẫn tối ưu hóa

  • Kiểm tra các bộ tham số khác nhau để có hiệu suất tốt nhất
  • Thêm các chỉ số hoặc mẫu biểu đồ khác để lọc tín hiệu
  • Khám phá các cải tiến dừng lỗ động, sau
  • Áp dụng máy học để tự động tối ưu hóa các thông số
  • Phát triển các plugin dừng lỗ / lấy lợi nhuận tự động
  • Kiểm tra độ bền trên các sản phẩm và khung thời gian

Kết luận

Nhìn chung, đây là một chiến lược giao dịch trung hạn dễ hiểu và thực hiện. Nó tận dụng các sự đảo ngược xu hướng được xác định bằng đường trung bình động và nến khoảng cách, với một khuôn khổ kiểm soát rủi ro hợp lý. Mặc dù có thể cải thiện hơn nữa, logic cốt lõi linh hoạt cho ứng dụng rộng hơn thông qua điều chỉnh tham số, lọc tín hiệu vv.v.


/*backtest
start: 2024-01-18 00:00:00
end: 2024-01-25 00:00:00
period: 15m
basePeriod: 5m
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/
// © TradingInsights2

//@version=5
strategy("Ultimate 5EMA Strategy By PowerOfStocks", overlay=true)

Eusl = input.bool(false, title="Enable the Extra SL shown below")
usl = input.int(defval=5, title='Value to set SL number of points below-low or above-high', minval=1, maxval=100)
RiRe = input.int(defval=3, title='Risk to Reward Ratio', minval=1, maxval=25)
ShowSell = input.bool(true, 'Show Sell Signals')
ShowBuy = input.bool(false, 'Show Buy Signals')
BSWCon = input.bool(defval=false, title='Buy/Sell with Extra Condition - candle close')

// Moving Average 

ema5 = ta.ema(close, 5)
pema5 = plot(ema5, '5 Ema', color=color.new(#da1a1a, 0), linewidth=2)

var bool Short = na
var bool Long = na
var shortC = 0
var sslhitC = 0
var starhitC = 0
var float ssl = na
var float starl = na
var float star = na
var float sellat = na
var float alert_shorthigh = na
var float alert_shortlow = na
var line lssl = na
var line lstar = na
var line lsell = na
var label lssllbl = na
var label lstarlbl = na
var label lselllbl = na
var longC = 0
var lslhitC = 0
var ltarhitC = 0
var float lsl = na
var float ltarl = na
var float ltar = na
var float buyat = na
var float alert_longhigh = na
var float alert_longlow = na
var line llsl = na
var line lltar = na
var line lbuy = na
var label llsllbl = na
var label lltarlbl = na
var label lbuylbl = na

ShortWC = low[1] > ema5[1] and low[1] > low and shortC == 0 and close < close[1]
ShortWOC = low[1] > ema5[1] and low[1] > low and shortC == 0
Short := BSWCon ? ShortWC : ShortWOC
sslhit = high > ssl and shortC > 0 and sslhitC == 0
starhit = low < star and shortC > 0 and starhitC == 0
LongWC = high[1] < ema5[1] and high[1] < high and longC == 0 and close > close[1]
LongWOC = high[1] < ema5[1] and high[1] < high and longC == 0
Long := BSWCon ? LongWC : LongWOC
lslhit = low < lsl and longC > 0 and lslhitC == 0
ltarhit = high > ltar and longC > 0 and ltarhitC == 0

if Short and ShowSell
    shortC := shortC + 1
    sslhitC := 0
    starhitC := 0
    alert_shorthigh := high[1]
    if Eusl
        ssl := high[1] + usl
        starl := BSWCon ? ((high[1] - close) + usl) * RiRe : ((high[1] - low[1]) + usl) * RiRe
    else
        ssl := high[1]
        starl := BSWCon ? (high[1] - close) * RiRe : (high[1] - low[1]) * RiRe
    star := BSWCon ? close - starl : low[1] - starl
    sellat := BSWCon ? close : low[1]
    // lssl := line.new(bar_index, ssl, bar_index, ssl, color=color.new(#fc2d01, 45), style=line.style_dashed)
    // lstar := line.new(bar_index, star, bar_index, star, color=color.new(color.green, 45), style=line.style_dashed)
    // lsell := line.new(bar_index, sellat, bar_index, sellat, color=color.new(color.orange, 45), style=line.style_dashed)
    // lssllbl := label.new(bar_index, ssl, style=label.style_none, text='Stop Loss - Short' + ' (' + str.tostring(ssl) + ')', textcolor=color.new(#fc2d01, 35), color=color.new(#fc2d01, 35))
    // lstarlbl := label.new(bar_index, star, style=label.style_none, text='Target - Short' + ' (' + str.tostring(star) + ')', textcolor=color.new(color.green, 35), color=color.new(color.green, 35))
    // lselllbl := label.new(bar_index, sellat, style=label.style_none, text='Sell at' + ' (' + str.tostring(sellat) + ')', textcolor=color.new(color.orange, 35), color=color.new(color.orange, 35))

if sslhit == false and starhit == false and shortC > 0
    // line.set_x2(lssl, bar_index)
    // line.set_x2(lstar, bar_index)
    // line.set_x2(lsell, bar_index)
    sslhitC := 0
    starhitC := 0
else
    if sslhit
        shortC := 0
        sslhitC := sslhitC + 1
    else
        if starhit
            shortC := 0
            starhitC := starhitC + 1

if Long and ShowBuy
    longC := longC + 1
    lslhitC := 0
    ltarhitC := 0
    alert_longlow := low[1]
    if Eusl
        lsl := low[1] - usl
        ltarl := BSWCon ? ((close - low[1]) + usl) * RiRe : ((high[1] - low[1]) + usl) * RiRe
    else
        lsl := low[1]
        ltarl := BSWCon ? (close - low[1]) * RiRe : (high[1] - low[1]) * RiRe
    ltar := BSWCon ? close + ltarl : high[1] + ltarl
    buyat := BSWCon ? close : high[1]
    llsl := line.new(bar_index, lsl, bar_index, lsl, color=color.new(#fc2d01, 45), style=line.style_dotted)
    lltar := line.new(bar_index, ltar, bar_index, ltar, color=color.new(color.green, 45), style=line.style_dotted)
    lbuy := line.new(bar_index, buyat, bar_index, buyat, color=color.new(color.orange, 45), style=line.style_dotted)
    llsllbl := label.new(bar_index, lsl, style=label.style_none, text='Stop Loss - Long' + ' (' + str.tostring(lsl) + ')', textcolor=color.new(#fc2d01, 35), color=color.new(#fc2d01, 35))
    lltarlbl := label.new(bar_index, ltar, style=label.style_none, text='Target - Long' + ' (' + str.tostring(ltar) + ')', textcolor=color.new(color.green, 35), color=color.new(color.green, 35))
    lbuylbl := label.new(bar_index, buyat, style=label.style_none, text='Buy at' + ' (' + str.tostring(buyat) + ')', textcolor=color.new(color.orange, 35), color=color.new(color.orange, 35))

if lslhit == false and ltarhit == false and longC > 0
    // line.set_x2(llsl, bar_index)
    // line.set_x2(lltar, bar_index)
    // line.set_x2(lbuy, bar_index)
    lslhitC := 0
    ltarhitC := 0
else
    if lslhit
        longC := 0
        lslhitC := lslhitC + 1
    else
        if ltarhit
            longC := 0
            ltarhitC := ltarhitC + 1

strategy.entry("Buy", strategy.long, when=Long)
strategy.entry("Sell", strategy.short, when=Short)
strategy.close("ExitBuy", when=sslhit or starhit)
strategy.close("ExitSell", when=lslhit or ltarhit)

plotshape(ShowSell and Short, title='Sell', location=location.abovebar, offset=0, color=color.new(#e74c3c, 45), style=shape.arrowdown, size=size.normal, text='Sell', textcolor=color.new(#e74c3c, 55))
plotshape(ShowSell and sslhit, title='SL Hit - Short', location=location.abovebar, offset=0, color=color.new(#fc2d01, 25), style=shape.arrowdown, size=size.normal, text='SL Hit - Short', textcolor=color.new(#fc2d01, 25))
plotshape(ShowSell and starhit, title='Target Hit - Short', location=location.belowbar, offset=0, color=color.new(color.green, 45), style=shape.arrowup, size=size.normal, text='Target Hit - Short', textcolor=color.new(color.green, 55))
plotshape(ShowBuy and Long, title='Buy', location=location.belowbar, offset=0, color=color.new(#2ecc71, 45), style=shape.arrowup, size=size.normal, text='Buy', textcolor=color.new(#2ecc71, 55))
plotshape(ShowBuy and lslhit, title='SL Hit - Long', location=location.belowbar, offset=0, color=color.new(#fc2d01, 25), style=shape.arrowdown, size=size.normal, text='SL Hit - Long', textcolor=color.new(#fc2d01, 25))
plotshape(ShowBuy and ltarhit, title='Target Hit - Long', location=location.abovebar, offset=0, color=color.new(color.green, 45), style=shape.arrowup, size=size.normal, text='Target Hit - Long', textcolor=color.new(color.green, 55))

if ShowSell and Short
    alert("Go Short@ " + str.tostring(sellat) + " : SL@ " + str.tostring(ssl) + " : Target@ " + str.tostring(star) + " ", alert.freq_once_per_bar )

if ShowBuy and Long
    alert("Go Long@ " + str.tostring(buyat) + " : SL@ " + str.tostring(lsl) + " : Target@ " + str.tostring(ltar) + " ", alert.freq_once_per_bar )

///// End of code

Thêm nữa