Chiến lược đột phá RSI nhanh gấp đôi

Tác giả:ChaoZhang, Ngày: 2023-11-07 16:56:39
Tags:

img

Tổng quan

Chiến lược này sử dụng nhiều chỉ số RSI để thực hiện đột phá giá để tạo ra các tín hiệu vào và ra chính xác hơn.

Chiến lược logic

Chiến lược đặt ra hai nhóm các thông số RSI, một với khoảng thời gian 7 và giới hạn 25, còn lại với khoảng thời gian 14 và giới hạn 25. Khi giá vượt qua giới hạn RSI, lệnh dài hoặc ngắn được thực hiện.

Chiến lược đầu tiên tính toán các giá trị của hai chỉ số RSI, sau đó đánh giá xem giá có vượt qua giới hạn trên hoặc dưới của RSI không. Nếu nó vượt qua giới hạn trên, một tín hiệu dài được tạo ra. Nếu nó vượt qua giới hạn dưới, một tín hiệu ngắn được tạo ra.

Nếu đã có vị trí, nó tiếp tục đánh giá xem RSI hiện tại có nằm trong phạm vi bình thường hay không.

Chiến lược này cũng sử dụng hệ thống Martingale.

Phân tích lợi thế

  • Sử dụng hai chỉ số RSI có thể đánh giá tốt hơn các tín hiệu đột phá và tránh các tín hiệu sai.

  • Ngoài ra kiểm tra cơ thể đột phá tránh giao dịch sai trong quá trình hợp nhất.

  • Martingale giúp dừng lỗ nhanh chóng sau khi thua lỗ.

  • Các thông số RSI có thể tùy chỉnh tối ưu hóa cơ hội nhập cảnh.

  • Các phiên giao dịch có thể được giới hạn để tránh tác động từ các sự kiện lớn.

Phân tích rủi ro

  • Chỉ số RSI kép không thể tránh hoàn toàn sự đột phá sai.

  • Martingale tăng vị trí sau khi thua lỗ, có nguy cơ nổ tung.

  • Chi phí giao dịch không được xem xét.

  • Quá nhiều thông số tối ưu hóa đòi hỏi rất nhiều thử nghiệm để tìm kết hợp tốt nhất.

Có thể thiết lập stop loss để hạn chế lỗ; tối ưu hóa các thông số RSI; thêm cân nhắc chi phí; thư giãn các tiêu chí đột phá.

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

  • Thêm stop loss để giới hạn lỗ tối đa.

  • Tối ưu hóa các thông số RSI để giảm tín hiệu sai.

  • Xem xét tác động của chi phí giao dịch để ngăn chặn giao dịch quá mức.

  • Dừng lại các tiêu chuẩn cơ thể để có thêm cơ hội.

  • Thêm thêm bộ lọc để tránh bị mắc kẹt.

Tóm lại

Chiến lược này sử dụng RSI kép để xác định sự đột phá giá, thêm bộ lọc đột phá cơ thể để tránh whipsaws. Nó cũng sử dụng Martingale để cắt giảm tổn thất nhanh chóng. Chiến lược có thể được cải thiện bằng cách tối ưu hóa các thông số và thêm bộ lọc cho các tín hiệu chính xác hơn. Quản lý rủi ro là quan trọng để hạn chế tổn thất. Nhìn chung chiến lược này cung cấp một hệ thống đột phá tương đối ổn định phù hợp với giao dịch hiệu quả cao.


/*backtest
start: 2023-10-30 00:00:00
end: 2023-11-06 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//Noro
//2018

//@version=2
strategy(title = "Noro's Fast RSI Strategy v2.0", shorttitle = "Fast RSI str 2.0", overlay = true)

//Settings
needlong = input(true, defval = true, title = "Long")
needshort = input(true, defval = true, title = "Short")
usemar = input(false, defval = false, title = "Use Martingale")
capital = input(100, defval = 100, minval = 1, maxval = 10000, title = "Capital, %")
usersi1 = input(true, defval = true, title = "Use RSI #1")
rsiperiod1 = input(7, defval = 7, minval = 2, maxval = 50, title = "#1 RSI Period")
rsilimit1 = input(25, defval = 25, minval = 1, maxval = 100, title = "#1 RSI limit")
usersi2 = input(true, defval = true, title = "Use RSI #2")
rsiperiod2 = input(14, defval = 14, minval = 2, maxval = 50, title = "#2 RSI Period")
rsilimit2 = input(25, defval = 25, minval = 1, maxval = 100, title = "#2 RSI limit")
showarr = input(false, defval = false, title = "Show Arrows")
fromyear = input(2018, defval = 2018, minval = 1900, maxval = 2100, title = "From Year")
toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")
frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")
tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month")
fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From day")
today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")

//RSI #1
uprsi1 = rma(max(change(close), 0), rsiperiod1)
dnrsi1 = rma(-min(change(close), 0), rsiperiod1)
rsi1 = dnrsi1 == 0 ? 100 : uprsi1 == 0 ? 0 : 100 - (100 / (1 + uprsi1 / dnrsi1))
uplimit1 = 100 - rsilimit1
dnlimit1 = rsilimit1

//RSI #2
uprsi2 = rma(max(change(close), 0), rsiperiod2)
dnrsi2 = rma(-min(change(close), 0), rsiperiod2)
rsi2 = dnrsi2 == 0 ? 100 : uprsi2 == 0 ? 0 : 100 - (100 / (1 + uprsi2 / dnrsi2))
uplimit2 = 100 - rsilimit2
dnlimit2 = rsilimit2

//Body
body = abs(close - open)
abody = sma(body, 10)

//Signals
bar = close > open ? 1 : close < open ? -1 : 0
up1 = bar == -1 and (strategy.position_size == 0 or close < strategy.position_avg_price) and rsi1 < dnlimit1 and body > abody / 5 and usersi1
dn1 = bar == 1 and (strategy.position_size == 0 or close > strategy.position_avg_price) and rsi1 > uplimit1 and body > abody / 5 and usersi1
up2 = bar == -1 and (strategy.position_size == 0 or close < strategy.position_avg_price) and rsi2 < dnlimit2 and body > abody / 5 and usersi2
dn2 = bar == 1 and (strategy.position_size == 0 or close > strategy.position_avg_price) and rsi2 > uplimit2 and body > abody / 5 and usersi2
norma = rsi1 > dnlimit1 and rsi1 < uplimit1 and rsi2 > dnlimit2 and rsi2 < uplimit2
exit = (((strategy.position_size > 0 and bar == 1 and norma) or (strategy.position_size < 0 and bar == -1 and norma)) and body > abody / 2)

//Arrows
col = exit ? black : up1 or dn1 ? blue : up2 or dn2 ? red : na
needup = up1 or up2
needdn = dn1 or dn2
needexitup = exit and strategy.position_size < 0
needexitdn = exit and strategy.position_size > 0
plotarrow(showarr and needup ? 1 : na, colorup = blue, colordown = blue, transp = 0)
plotarrow(showarr and needdn ? -1 : na, colorup = blue, colordown = blue, transp = 0)
plotarrow(showarr and needexitup ? 1 : na, colorup = black, colordown = black, transp = 0)
plotarrow(showarr and needexitdn ? -1 : na, colorup = black, colordown = black, transp = 0)

//Trading
profit = exit ? ((strategy.position_size > 0 and close > strategy.position_avg_price) or (strategy.position_size < 0 and close < strategy.position_avg_price)) ? 1 : -1 : profit[1]
mult = usemar ? exit ? profit == -1 ? mult[1] * 2 : 1 : mult[1] : 1
lot = strategy.position_size == 0 ? strategy.equity / close * capital / 100 * mult : lot[1]

if up1 or up2
    if strategy.position_size < 0
        strategy.close_all()
        
    strategy.entry("Long", strategy.long, needlong == false ? 0 : lot)

if dn1 or dn2
    if strategy.position_size > 0
        strategy.close_all()
        
    strategy.entry("Short", strategy.short, needshort == false ? 0 : lot)
    
if  exit
    strategy.close_all()

Thêm nữa