Chiến lược giao dịch đột phá chỉ báo RSI nhanh


Ngày tạo: 2023-09-12 16:34:21 sửa đổi lần cuối: 2023-09-12 16:34:21
sao chép: 0 Số nhấp chuột: 797
1
tập trung vào
1617
Người theo dõi

Chiến lược này sử dụng chỉ số RSI nhanh để xác định hiện tượng quá mua quá bán và thực hiện giao dịch đảo ngược. Chiến lược này kết hợp với các biến động lớn và nhỏ của thực thể K-line để tránh bị mắc kẹt. Chiến lược này tìm kiếm sự phán đoán nhanh chóng về hiện tượng quá mua quá bán và nắm bắt cơ hội đảo ngược kịp thời.

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

  1. Tính toán giá trị chỉ số RSI nhanh, thiết lập ngưỡng thâm hụt quá mua quá bán.

  2. Tính toán EMA trung bình của kích thước thực thể đường K để xác định kích thước thực thể.

  3. RSI vượt qua đường mua quá mức và thực thể lớn hơn một nửa giá trị trung bình. RSI vượt qua đường bán quá mức và thực thể lớn hơn một nửa giá trị trung bình.

  4. RSI sẽ giảm xuống khi giá trị lớn hơn giá trị trung bình.

  5. Bạn có thể xác minh thêm bằng cách kết hợp giá trị tối thiểu với giá trị tối đa.

Những lợi thế của chiến lược này:

  1. RSI nhanh có thể đánh giá được giá trị mua và bán nhanh chóng, tránh bị tụt hậu.

  2. Sóng kích thước thực thể có thể vượt qua các đường K không rõ ràng.

  3. Xác minh giá trị tối đa tối thiểu giúp cải thiện chất lượng tín hiệu.

Rủi ro của chiến lược này:

  1. Phân tích kích thước thực thể có thể lọc một số tín hiệu hiệu quả.

  2. RSI có thể có tín hiệu giả trong các trường hợp chấn động.

  3. Cần quản lý tài chính nghiêm ngặt để đối phó với rủi ro của các giao dịch đảo ngược.

Tóm lại, chiến lược này sử dụng RSI nhanh và chỉ số kích thước thực thể K-line để giao dịch kết hợp, kiểm soát rủi ro trong khi nhanh chóng xác định quá mua quá bán, có hiệu quả tốt hơn. Tuy nhiên, cần cảnh giác về vấn đề lọc, đồng thời triển khai các phương tiện quản lý tiền tốt.

Mã nguồn chiến lược
/*backtest
start: 2023-01-01 00:00:00
end: 2023-09-11 00:00:00
period: 2d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
strategy(title = "Noro's Fast RSI Strategy v1.3", shorttitle = "Fast RSI str 1.3", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 5)

//Settings
needlong = input(true, defval = true, title = "Long")
needshort = input(true, defval = true, title = "Short")
rsiperiod = input(7, defval = 7, minval = 2, maxval = 50, title = "RSI Period")
limit = input(30, defval = 30, minval = 1, maxval = 100, title = "RSI limit")
rsisrc = input(close, defval = close, title = "RSI Price")
rb = input(1, defval = 1, minval = 1, maxval = 5, title = "RSI Bars")
usemm = input(false, defval = false, title = "Use Min/Max")
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")

//Fast RSI
fastup = rma(max(change(rsisrc), 0), rsiperiod)
fastdown = rma(-min(change(rsisrc), 0), rsiperiod)
fastrsi = fastdown == 0 ? 100 : fastup == 0 ? 0 : 100 - (100 / (1 + fastup / fastdown))

//Limits
bar = close > open ? 1 : close < open ? -1 : 0
uplimit = 100 - limit
dnlimit = limit

//RSI Bars
ur = fastrsi > uplimit
dr = fastrsi < dnlimit
uprsi = rb == 1 and ur ? 1 : rb == 2 and ur and ur[1] ? 1 : rb == 3 and ur and ur[1] and ur[2] ? 1 : rb == 4 and ur and ur[1] and ur[2] and ur[3] ? 1 : rb == 5 and ur and ur[1] and ur[2] and ur[3] and ur[4] ? 1 : 0
dnrsi = rb == 1 and dr ? 1 : rb == 2 and dr and dr[1] ? 1 : rb == 3 and dr and dr[1] and dr[2] ? 1 : rb == 4 and dr and dr[1] and dr[2] and dr[3] ? 1 : rb == 5 and dr and dr[1] and dr[2] and dr[3] and dr[4] ? 1 : 0

//Body
body = abs(close - open)
emabody = ema(body, 30)

//MinMax
min = min(close, open)
max = max(close, open)

//Signals
up1 = bar == -1 and (strategy.position_size == 0 or close < strategy.position_avg_price) and dnrsi and body > emabody / 4
dn1 = bar == 1 and (strategy.position_size == 0 or close > strategy.position_avg_price) and uprsi and body > emabody / 4
up2 = min < min[1] and bar == -1 and bar[1] == -1 and usemm
dn2 = max > max[1] and bar == 1 and bar[1] == 1 and usemm
exit = ((strategy.position_size > 0 and fastrsi > dnlimit and bar == 1) or (strategy.position_size < 0 and fastrsi < uplimit and bar == -1)) and body > emabody / 2

//Arrows
col = exit ? black : up1 or dn1 ? blue : up2 or dn2 ? red : na
needup = up1 or (up2 and usemm)
needdn = dn1 or (dn2 and usemm)
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
if up1 or up2
    strategy.entry("Long", strategy.long, needlong == false ? 0 : na, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 00, 00)))

if dn1 or dn2
    strategy.entry("Short", strategy.short, needshort == false ? 0 : na, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 00, 00)))
    
if time > timestamp(toyear, tomonth, today, 00, 00) or exit
    strategy.close_all()