Chiến lược giao dịch hồi quy RSI đa cấp và điều chỉnh biến động động

RSI、PIVOT
Ngày tạo: 2024-06-21 14:16:31 sửa đổi lần cuối: 2024-06-21 14:16:31
sao chép: 0 Số nhấp chuột: 567
1
tập trung vào
1617
Người theo dõi

Chiến lược giao dịch hồi quy RSI đa cấp và điều chỉnh biến động động

Tổng quan

Chiến lược này là một hệ thống giao dịch quay trở lại giá trị trung bình nhiều cấp dựa trên chỉ số RSI và biến động giá. Nó sử dụng giá trị cực đoan và biến động giá lớn bất thường của RSI làm tín hiệu đầu vào, đồng thời sử dụng tăng cường kim tự tháp và dừng động để quản lý rủi ro và tối ưu hóa lợi nhuận. Ý tưởng cốt lõi của chiến lược này là vào thị trường khi có biến động cực đoan và thu lợi nhuận khi giá trở lại mức bình thường.

Nguyên tắc chiến lược

  1. Điều kiện tham gia:

    • Sử dụng 20 chu kỳ RSI ((RSI20) như là chỉ số chính
    • Thiết lập nhiều ngưỡng RSI ((3565, 3070, 2575, 2080) và ngưỡng dao động tương ứng
    • Khi RSI đạt đến một ngưỡng nhất định và kích thước hiện tại của thực thể K-line vượt quá ngưỡng dao động tương ứng, nó sẽ kích hoạt tín hiệu nhập cảnh
    • Điều kiện bổ sung: Giá cần phá vỡ mức hỗ trợ cao nhất / thấp nhất định
  2. Cơ chế gia tăng:

    • Tối đa 5 lần đầu tư được phép ((đầu tư ban đầu + 4 lần gia tăng)
    • Mỗi lần đặt cược cần phải đáp ứng các điều kiện RSI và biến động nghiêm ngặt hơn
  3. Cơ chế ra sân:

    • Thiết lập 5 điểm dừng khác nhau
    • Điểm dừng dựa trên tính toán động lực hỗ trợ / kháng cự khi vào
    • Mục tiêu giảm dần khi số lượng nắm giữ tăng lên
  4. Kiểm soát rủi ro:

    • Sử dụng mô hình rủi ro phần trăm, rủi ro mỗi giao dịch được cố định là 20% tổng giá trị tài khoản
    • Thiết lập tối đa cho phép 5 vị trí đồng thời, giới hạn lỗ hổng rủi ro tổng thể

Lợi thế chiến lược

  1. Nhiều cấp độ nhập: Bằng cách thiết lập nhiều RSI và ngưỡng biến động, chiến lược có thể nắm bắt các mức độ khác nhau của các tình huống cực đoan của thị trường, tăng cơ hội giao dịch.

  2. Động lực dừng: dựa trên hỗ trợ / kháng cự điểm dừng tính toán, có thể điều chỉnh tùy theo cấu trúc thị trường, cả hai bảo vệ lợi nhuận và không rời khỏi sân quá sớm.

  3. Lưu trữ theo kiểu kim tự tháp: Tăng số lượng nắm giữ khi xu hướng tiếp tục, có thể làm tăng đáng kể tiềm năng lợi nhuận.

  4. Quản lý rủi ro: Kiểm soát hiệu quả rủi ro trên mỗi giao dịch và rủi ro tổng thể bằng cách cố định tỷ lệ rủi ro và giới hạn nắm giữ tối đa.

  5. Tính linh hoạt: Một số tham số có thể điều chỉnh cho phép chiến lược thích ứng với các môi trường thị trường và các loại giao dịch khác nhau.

  6. Phản hồi trung bình + theo dõi xu hướng: kết hợp các lợi ích của Phản hồi trung bình và theo dõi xu hướng, có thể nắm bắt được sự đảo ngược ngắn hạn và không bỏ lỡ xu hướng lớn.

Rủi ro chiến lược

  1. Giao dịch quá mức: có thể thường xuyên kích hoạt tín hiệu giao dịch trong thị trường biến động cao, dẫn đến phí xử lý quá cao.

  2. Lỗi đột phá giả: Thị trường có thể có những biến động cực đoan ngắn ngủi sau khi hồi phục nhanh chóng, gây ra tín hiệu sai.

  3. Mất liên tục: Nếu thị trường tiếp tục di chuyển một chiều, nó có thể dẫn đến mất mát lớn sau nhiều lần gia tăng.

  4. Tính nhạy cảm của tham số: Hiệu suất của chiến lược có thể rất nhạy cảm với cài đặt tham số, có nguy cơ quá phù hợp.

  5. Tác động của điểm trượt: Trong thời gian biến động mạnh, có thể có điểm trượt nghiêm trọng ảnh hưởng đến hiệu suất chiến lược.

  6. Tùy thuộc vào môi trường thị trường: Chiến lược có thể không hoạt động tốt trong một số môi trường thị trường, chẳng hạn như thị trường biến động thấp hoặc xu hướng mạnh.

Hướng tối ưu hóa chiến lược

  1. Điều chỉnh tham số động: giới thiệu cơ chế thích ứng, điều chỉnh RSI và giá trị giảm biến động theo tình trạng thị trường.

  2. Phân tích nhiều chu kỳ thời gian: kết hợp với xu hướng thị trường lâu dài hơn, cải thiện chất lượng nhập cảnh.

  3. Tối ưu hóa Stop Loss: Tăng Stop Loss theo dõi hoặc Stop Loss động dựa trên ATR để kiểm soát rủi ro hơn nữa.

  4. Trình lọc trạng thái thị trường: Thêm các điều kiện lọc như cường độ xu hướng, chu kỳ biến động và tránh giao dịch trong môi trường thị trường không phù hợp.

  5. Tối ưu hóa quản lý tiền: thực hiện quản lý vị trí chi tiết hơn, chẳng hạn như điều chỉnh quy mô giao dịch theo các mức tín hiệu khác nhau.

  6. Tích hợp học máy: Sử dụng các thuật toán học máy để tối ưu hóa lựa chọn tham số và quá trình tạo tín hiệu

  7. Phân tích liên quan: Thêm vào phân tích liên quan với các tài sản khác, tăng sự ổn định và đa dạng của chiến lược.

Tóm tắt

Chiến lược giao dịch quay trở RSI đa tầng là một hệ thống giao dịch định lượng được thiết kế cẩn thận, nó kết hợp một cách khéo léo các kỹ thuật phân tích kỹ thuật, quản lý rủi ro động và kỹ thuật tăng cường theo kiểu kim tự tháp. Chiến lược này thể hiện tiềm năng lợi nhuận mạnh mẽ bằng cách nắm bắt sự biến động cực đoan của thị trường và lợi nhuận khi giá quay trở lại. Tuy nhiên, nó cũng đối mặt với những thách thức như giao dịch quá mức và phụ thuộc vào môi trường thị trường.

Mã nguồn chiến lược
/*backtest
start: 2024-05-01 00:00:00
end: 2024-05-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy('Retorno_Pivots_5min_Novo_v3.3')

// Input variables
bars_left1 = input(1, title = "Entry - Pivot Left Bars")
bars_right1 = input(1, title = "Entry - Pivot Right Bars")
rsi20_longentry0 = input(35, title = "Entry 1 - RSI20 Long")
rsi20_shortentry0 = input(65, title = "Entry 1 - RSI20 Short")
bar_size_entry0 = input.float(1, title="Entry 1 - Bar Size")
rsi20_longentry1 = input(30, title = "Entry 2 - RSI20 Long")
rsi20_shortentry1 = input(70, title = "Entry 2 - RSI20 Short")
bar_size_entry1 = input.float(0.8, title="Entry 2 - Bar Size")
rsi20_longentry2 = input(25, title = "Entry 3 - RSI20 Long")
rsi20_shortentry2 = input(75, title = "Entry 3 - RSI20 Short")
bar_size_entry2 = input.float(0.7, title="Entry 3 - Bar Size")
rsi20_longentry3 = input(20, title = "Entry 4 - RSI20 Long")
rsi20_shortentry3 = input(80, title = "Entry 4 - RSI20 Short")
bar_size_entry3 = input.float(0.5, title="Entry 4 - Bar Size")
limit_perc1 = input.float(0.60, title="Profit Range 1")
limit_perc2 = input.float(0.40, title="Profit Range 2")
limit_perc3 = input.float(0.20, title="Profit Range 3")
limit_perc4 = input.float(0.00, title="Profit Range 4")
limit_perc5 = input.float(0.00, title="Profit Range 5")
minimum_pivot_distance = input.float(0, title="Minimum Pivot Distance %")
barsize_1h_input = input(288, title="Highest Bar Lookback")
rsi20 = ta.rsi(close, 20)
rsi200 = ta.rsi(close, 200)
Pivot_High_Last1 = ta.valuewhen(ta.pivothigh(high, bars_left1, bars_right1), ta.pivothigh(high, bars_left1, bars_right1), 0)
Pivot_Low_Last1 = ta.valuewhen(ta.pivotlow(low, bars_left1, bars_right1), ta.pivotlow(low, bars_left1, bars_right1), 0)

barsize = math.abs(close - open)
barsize_1h = ta.highest(barsize, barsize_1h_input)

Bar0Long = rsi20 < rsi20_longentry0 and barsize >= (barsize_1h * bar_size_entry0)
Bar1Long = rsi20 < rsi20_longentry1 and barsize >= (barsize_1h * bar_size_entry1)
Bar2Long = rsi20 < rsi20_longentry2 and barsize >= (barsize_1h * bar_size_entry2)
Bar3Long = rsi20 < rsi20_longentry3 and barsize >= (barsize_1h * bar_size_entry3)

// Long Entries
Long_Entry1 = strategy.opentrades == 0 and rsi20 < rsi20[1] and ((rsi20 < rsi20_longentry0 and barsize >= (barsize_1h * bar_size_entry0)) or (rsi20 < rsi20_longentry1 and barsize >= (barsize_1h * bar_size_entry1)) or (rsi20 < rsi20_longentry2 and barsize >= (barsize_1h * bar_size_entry2)) or (rsi20 < rsi20_longentry3 and barsize >= (barsize_1h * bar_size_entry3))) and close < (Pivot_Low_Last1 * (1 - (minimum_pivot_distance / 100)))
Long_Entry2 = strategy.opentrades == 1 and strategy.position_size > 0 and rsi20 < rsi20[1] and (Bar0Long or Bar1Long or Bar2Long or Bar3Long)
Long_Entry3 = strategy.opentrades == 2 and strategy.position_size > 0 and rsi20 < rsi20[1] and (Bar0Long or Bar1Long or Bar2Long or Bar3Long)
Long_Entry4 = strategy.opentrades == 3 and strategy.position_size > 0 and rsi20 < rsi20[1] and (Bar0Long or Bar1Long or Bar2Long or Bar3Long)
Long_Entry5 = strategy.opentrades == 4 and strategy.position_size > 0 and rsi20 < rsi20[1] and (Bar0Long or Bar1Long or Bar2Long or Bar3Long)
if Long_Entry1 or Long_Entry2 or Long_Entry3 or Long_Entry4 or Long_Entry5
    strategy.entry("Long", strategy.long, comment = "ENTER-LONG_BINANCE-FUTURES_BTCBUSD_Bot-BTC-1min_1M_970d2ee265390c27")
// Longs Exits
Long_Exit1 = strategy.opentrades == 1 and close > (strategy.position_avg_price + ((ta.valuewhen(strategy.opentrades == 0, Pivot_Low_Last1, 0) - (strategy.position_avg_price)) * limit_perc1))
Long_Exit2 = strategy.opentrades == 2 and close > (strategy.position_avg_price + ((ta.valuewhen(strategy.opentrades == 0, Pivot_Low_Last1, 0) - (strategy.position_avg_price)) * limit_perc2))
Long_Exit3 = strategy.opentrades == 3 and close > (strategy.position_avg_price + ((ta.valuewhen(strategy.opentrades == 0, Pivot_Low_Last1, 0) - (strategy.position_avg_price)) * limit_perc3))
Long_Exit4 = strategy.opentrades == 4 and close > (strategy.position_avg_price + ((ta.valuewhen(strategy.opentrades == 0, Pivot_Low_Last1, 0) - (strategy.position_avg_price)) * limit_perc4))
Long_Exit5 = strategy.opentrades == 5 and close > (strategy.position_avg_price + ((ta.valuewhen(strategy.opentrades == 0, Pivot_Low_Last1, 0) - (strategy.position_avg_price)) * limit_perc5))
if Long_Exit1 or Long_Exit2 or Long_Exit3 or Long_Exit4 or Long_Exit5
    strategy.close("Long", comment = "EXIT-LONG_BINANCE-FUTURES_BTCBUSD_Bot-BTC-1min_1M_970d2ee265390c27")

Bar0Short = rsi20 > rsi20_shortentry0 and barsize >= (barsize_1h * bar_size_entry0)
Bar1Short = rsi20 > rsi20_shortentry1 and barsize >= (barsize_1h * bar_size_entry1)
Bar2Short = rsi20 > rsi20_shortentry2 and barsize >= (barsize_1h * bar_size_entry2)
Bar3Short = rsi20 > rsi20_shortentry3 and barsize >= (barsize_1h * bar_size_entry3)

// Short Entries
Short_Entry1 = strategy.opentrades == 0 and rsi20 > rsi20[1] and ((rsi20 > rsi20_shortentry0 and barsize >= (barsize_1h * bar_size_entry0)) or (rsi20 > rsi20_shortentry1 and barsize >= (barsize_1h * bar_size_entry1)) or (rsi20 > rsi20_shortentry2 and barsize >= (barsize_1h * bar_size_entry2)) or (rsi20 > rsi20_shortentry2 and barsize >= (barsize_1h * bar_size_entry2))) and close > (Pivot_High_Last1 * (1 + (minimum_pivot_distance / 100)))
Short_Entry2 = strategy.opentrades == 1 and strategy.position_size < 0 and rsi20 > rsi20[1] and (Bar0Short or Bar1Short or Bar2Short or Bar3Short)
Short_Entry3 = strategy.opentrades == 2 and strategy.position_size < 0 and rsi20 > rsi20[1] and (Bar0Short or Bar1Short or Bar2Short or Bar3Short)
Short_Entry4 = strategy.opentrades == 3 and strategy.position_size < 0 and rsi20 > rsi20[1] and (Bar0Short or Bar1Short or Bar2Short or Bar3Short)
Short_Entry5 = strategy.opentrades == 4 and strategy.position_size < 0 and rsi20 > rsi20[1] and (Bar0Short or Bar1Short or Bar2Short or Bar3Short)
if Short_Entry1 or Short_Entry2 or Short_Entry3 or Short_Entry4 or Short_Entry5
    strategy.entry("Short", strategy.short, comment = "ENTER-SHORT_BINANCE-FUTURES_BTCBUSD_Bot-BTC-1min_1M_970d2ee265390c27")
// Short Exits
Short_Exit1 = strategy.opentrades == 1 and close < (strategy.position_avg_price - ((strategy.position_avg_price - ta.valuewhen(strategy.opentrades == 0, Pivot_High_Last1, 0)) * limit_perc1))
Short_Exit2 = strategy.opentrades == 2 and close < (strategy.position_avg_price - ((strategy.position_avg_price - ta.valuewhen(strategy.opentrades == 0, Pivot_High_Last1, 0)) * limit_perc2))
Short_Exit3 = strategy.opentrades == 3 and close < (strategy.position_avg_price - ((strategy.position_avg_price - ta.valuewhen(strategy.opentrades == 0, Pivot_High_Last1, 0)) * limit_perc3))
Short_Exit4 = strategy.opentrades == 4 and close < (strategy.position_avg_price - ((strategy.position_avg_price - ta.valuewhen(strategy.opentrades == 0, Pivot_High_Last1, 0)) * limit_perc4))
Short_Exit5 = strategy.opentrades == 5 and close < (strategy.position_avg_price - ((strategy.position_avg_price - ta.valuewhen(strategy.opentrades == 0, Pivot_High_Last1, 0)) * limit_perc5))
if Short_Exit1 or Short_Exit2 or Short_Exit3 or Short_Exit4 or Short_Exit5
    strategy.close("Short", comment = "EXIT-SHORT_BINANCE-FUTURES_BTCBUSD_Bot-BTC-1min_1M_970d2ee265390c27")

// Plots
plot(rsi20, color=color.new(#fbff00, 0), linewidth=2)
plot(((strategy.position_avg_price + ((ta.valuewhen(strategy.opentrades == 0, Pivot_Low_Last1, 0) - (strategy.position_avg_price)) * limit_perc1))), color=color.new(#00ff2a, 0), linewidth=2)
plot(((strategy.position_avg_price + ((ta.valuewhen(strategy.opentrades == 0, Pivot_Low_Last1, 0) - (strategy.position_avg_price)) * limit_perc2))), color=color.new(#00ff2a, 50), linewidth=2)
plot(((strategy.position_avg_price + ((ta.valuewhen(strategy.opentrades == 0, Pivot_Low_Last1, 0) - (strategy.position_avg_price)) * limit_perc3))), color=color.new(#00ff2a, 80), linewidth=2)
plot(((strategy.position_avg_price + ((ta.valuewhen(strategy.opentrades == 0, Pivot_Low_Last1, 0) - (strategy.position_avg_price)) * limit_perc4))), color=color.new(#00ff2a, 100), linewidth=2)
plot((strategy.position_avg_price - ((strategy.position_avg_price - ta.valuewhen(strategy.opentrades == 0, Pivot_High_Last1, 0)) * limit_perc1)), color=color.new(#ff0000, 0), linewidth=2)
plot((strategy.position_avg_price - ((strategy.position_avg_price - ta.valuewhen(strategy.opentrades == 0, Pivot_High_Last1, 0)) * limit_perc2)), color=color.new(#ff0000, 50), linewidth=2)
plot((strategy.position_avg_price - ((strategy.position_avg_price - ta.valuewhen(strategy.opentrades == 0, Pivot_High_Last1, 0)) * limit_perc3)), color=color.new(#ff0000, 80), linewidth=2)
plot((strategy.position_avg_price - ((strategy.position_avg_price - ta.valuewhen(strategy.opentrades == 0, Pivot_High_Last1, 0)) * limit_perc4)), color=color.new(#ff0000, 100), linewidth=2)
plot(strategy.position_avg_price, color=color.new(#ffc400, 0), linewidth=2)
plot(strategy.opentrades * (strategy.position_size / math.abs(strategy.position_size)), color=color.new(#ff00bb, 0), linewidth=2)
plot(((barsize / barsize_1h) * 100), color=color.new(#0000ff, 0), linewidth=2)