Bollinger Bands RSI Chiến lược giao dịch swing

Tác giả:ChaoZhang, Ngày: 2023-09-16 18:48:44
Tags:

Tổng quan

Chiến lược giao dịch xoay Bollinger Bands RSI kết hợp các chỉ số Bollinger Bands và Chỉ số sức mạnh tương đối (RSI) để giao dịch dao động phạm vi ngắn hạn.

Nguyên tắc

Đầu tiên, chỉ số Bollinger Bands phân tích phạm vi biến động giá. Giá gần dải trên được mua quá mức, trong khi giá gần dải dưới được bán quá mức.

Thứ hai, chỉ số RSI xác định sức mạnh mua quá mức / bán quá mức.

Khi giá đạt đến dải dưới và chỉ số RSI cho thấy quá bán, mua dài.

Ưu điểm

  • Bollinger Bands xác định chính xác mức độ biến động giá.

  • RSI tránh các mục nhập dài / ngắn mù.

  • Tỷ lệ thắng cao tận dụng sự đảo ngược trung bình.

  • Giao dịch thường xuyên cho phép lợi nhuận bền vững.

  • Áp dụng cho các sản phẩm và khung thời gian khác nhau.

Rủi ro

  • Các thông số BB không chính xác không thể xác định các mức chính.

  • Các thông số RSI xấu tạo ra tín hiệu sai.

  • Không có sự khôi phục đủ kích hoạt dừng lỗ.

  • Tần suất giao dịch cao dẫn đến chi phí trượt lớn hơn.

  • Khó để theo dõi xu hướng trong thị trường biến động.

Quản lý rủi ro

  • Tối ưu hóa các thông số để BBs phù hợp với biến động thực tế.

  • Điều chỉnh thời gian RSI để lọc ra tiếng ồn.

  • Sử dụng các điểm dừng để giảm lợi nhuận.

  • Chọn các sản phẩm lỏng để giảm thiểu tác động trượt.

  • Thêm các chỉ số khác để xác định hướng xu hướng.

Tóm lại

Chiến lược giao dịch dao động BB RSI có hiệu quả nắm bắt các biến động giá hai chiều trong phạm vi. Với điều chỉnh tham số và quản lý rủi ro thích hợp, nó cung cấp lợi nhuận ổn định. Đây là một chiến lược giao dịch lượng ngắn hạn được khuyến cáo.


/*backtest
start: 2023-08-16 00:00:00
end: 2023-09-15 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy("Swing trading strategy FOREX ", shorttitle="BB+RSI", overlay=true)

////////////////////////////////////////////////////////////////////////////////
// BACKTESTING RANGE
 
// From Date Inputs
fromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
fromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
fromYear = input(defval = 2020, title = "From Year", minval = 1970)
 
// To Date Inputs
toDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
toMonth = input(defval = 1, title = "To Month", minval = 1, maxval = 12)
toYear = input(defval = 2022, title = "To Year", minval = 1970)
 
// Calculate start/end date and time condition
startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00)
finishDate = timestamp(toYear, toMonth, toDay, 00, 00)
time_cond = true
// 
// 


///////////// RSI
RSIlength = input(6,title="RSI Period Length") 
RSIoverSold = input(defval = 65, title = "RSIoverSold", minval = 1, maxval = 100)
RSIoverBought = input(defval = 35, title = "RSIoverBought", minval = 1, maxval = 100)
price = close
vrsi = rsi(price, RSIlength)



///////////// Bollinger Bands
BBlength = input(200, minval=1,title="Bollinger Period Length")
BBmult = 2 // input(2.0, minval=0.001, maxval=50,title="Bollinger Bands Standard Deviation")
BBbasis = sma(price, BBlength)
BBdev = BBmult * stdev(price, BBlength)
BBupper = BBbasis + BBdev
BBlower = BBbasis - BBdev
source = close
buyEntry = crossover(source, BBlower)
sellEntry = crossunder(source, BBupper)
plot(BBbasis, color=color.aqua,title="Bollinger Bands SMA Basis Line")
p1 = plot(BBupper, color=color.silver,title="Bollinger Bands Upper Line")
p2 = plot(BBlower, color=color.silver,title="Bollinger Bands Lower Line")
fill(p1, p2)


///////////// Colors
switch1=input(true, title="Enable Bar Color?")
switch2=input(true, title="Enable Background Color?")
TrendColor = RSIoverBought and (price[1] > BBupper and price < BBupper) and BBbasis < BBbasis[1] ? color.red : RSIoverSold and (price[1] < BBlower and price > BBlower) and BBbasis > BBbasis[1] ? color.green : na
barcolor(switch1?TrendColor:na)
bgcolor(switch2?TrendColor:na,transp=50)


///////////// RSI + Bollinger Bands Strategy
//for buy
cond1=crossover(vrsi, RSIoverSold)
cond2=crossover(source, BBlower) 
//for sell
cond3=crossunder(vrsi, RSIoverBought)
cond4=crossunder(source, BBupper)
if (not na(vrsi))

    if (cond1 and cond2 and time_cond)
        strategy.entry("RSI_BB_LONG", strategy.long, stop=BBlower, comment="LONG",alert_message = "long")
    else
        strategy.cancel(id="RSI_BB_LONG")
        
    if (cond3 and cond4 and time_cond)
        strategy.entry("RSI_BB_SHORT", strategy.short, stop=BBupper,  comment="SHORT",alert_message = "short")
        //strategy.close("RSI_BB_LONG")

    else
        strategy.cancel(id="RSI_BB_SHORT")
        
//strategy.exit("closelong", "RSI_BB_LONG" , profit = close * 0.01 / syminfo.mintick, loss = close * 0.01 / syminfo.mintick, alert_message = "closelong")
//strategy.exit("closeshort", "RSI_BB_SHORT" , profit = close * 0.01 / syminfo.mintick, loss = close * 0.01 / syminfo.mintick, alert_message = "closeshort")


//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)

Thêm nữa