Chiến lược giao dịch chuyển động mô hình RSI hình chữ V

Tác giả:ChaoZhang, Ngày: 2024-01-12 13:52:55
Tags:

img

Tổng quan

Chiến lược này dựa trên mô hình hình V được hình thành bởi chỉ số RSI, kết hợp với các bộ lọc EMA, để phát triển một chiến lược giao dịch có lợi nhuận ngắn hạn đáng tin cậy. Nó nắm bắt các cơ hội phục hồi khi giá được bán quá mức bằng cách đi dài chính xác thông qua các tín hiệu hình V của RSI, với mục đích kiếm lợi nhuận trong ngắn hạn.

Chiến lược logic

  1. Sử dụng EMA 20 ngày trên EMA 50 ngày để đánh giá xu hướng tăng dài hạn
  2. RSI hình thành mô hình hình chữ V, cho thấy cơ hội phục hồi quá bán
    • Tối thiểu của 2 thanh trước thấp hơn 2 thanh trước
    • RSI bar hiện tại cao hơn 2 bar RSI trước đó
  3. RSI vượt trên 30 như là tín hiệu hoàn thành mô hình hình V để đi dài
  4. Đặt mức dừng lỗ ở mức 8% dưới giá nhập cảnh
  5. Khi chỉ số RSI vượt qua 70, bắt đầu đóng các vị trí và di chuyển dừng lỗ đến giá nhập cảnh
  6. Khi RSI vượt qua 90, đóng 3/4 vị trí
  7. Khi RSI đi dưới 10 / dừng lỗ được kích hoạt, đóng tất cả các vị trí

Phân tích lợi thế

  1. Sử dụng EMA để đánh giá hướng thị trường tổng thể, tránh giao dịch chống lại xu hướng
  2. RSI mô hình hình V nắm bắt cơ hội đảo ngược trung bình khi bán quá mức
  3. Nhiều cơ chế dừng lỗ để kiểm soát rủi ro

Phân tích rủi ro

  1. Xu hướng giảm mạnh có thể gây ra tổn thất không thể ngăn chặn
  2. RSI V-shaped tín hiệu có thể cung cấp tín hiệu sai, dẫn đến tổn thất không cần thiết

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

  1. Tối ưu hóa các thông số RSI để tìm các mẫu hình V đáng tin cậy hơn
  2. Bao gồm các chỉ số khác để tăng độ tin cậy của tín hiệu đảo ngược
  3. Cải thiện chiến lược dừng lỗ, cân bằng giữa ngăn ngừa quá hung hăng và dừng lỗ kịp thời

Tóm lại

Chiến lược này tích hợp bộ lọc EMA và phán đoán mô hình hình RSI V để tạo thành một chiến lược giao dịch ngắn hạn đáng tin cậy. Nó có thể nắm bắt hiệu quả các cơ hội phục hồi khi bán quá mức. Với việc tối ưu hóa liên tục các thông số và mô hình, cải thiện cơ chế dừng lỗ, chiến lược này có thể được tăng cường hơn nữa về tính ổn định và lợi nhuận. Nó mở ra cánh cửa cho giao dịch swing có lợi nhuận cho các nhà giao dịch lượng.


/*backtest
start: 2023-12-12 00:00:00
end: 2024-01-11 00:00:00
period: 1h
basePeriod: 15m
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/
// © mohanee

//@version=4
//strategy("RSI V Pattern", overlay=true)
strategy(title="RSI V Pattern", overlay=false )

//Strategy Rules
//ema20 is above ema50  --- candles are colored  green on the chart
//RSI value sharply coming up which makes a V shape ,  colored in yellow on the chart
//RSI V pattern should occur from below 30    

len = input(title="RSI Period", minval=1, defval=5)
stopLoss = input(title="Stop Loss %", minval=1, defval=8)

myRsi = rsi(close,len)

longEmaVal=ema(close,50)
shortEmaVal=ema(close,20)

//plot emas 
//plot(longEmaVal, title="Long EMA" ,linewidth=2, color=color.orange, trackprice=true)
//plot(shortEmaVal, title="Short EMA" ,linewidth=2, color=color.green, trackprice=true)


longCondition =  ema(close,20)>ema(close,50)   and (low[1]<low[2] and  low[1]<low[3]) and (myRsi>myRsi[1] and myRsi>myRsi[2] ) and crossover(myRsi,30) //  (   and myRsi<60)  

//(myRsi<60 and myRsi>30)  and myRsi>myRsi[1] and (myRsi[1]<myRsi[2]  or  myRsi[1]<myRsi[3]) and (myRsi[2]<30)  and (myRsi[3]<30 and myRsi[4]>=30)



barcolor(shortEmaVal>longEmaVal?color.green:color.red)
//longCondition = crossover(sma(close, 14), sma(close, 28))
barcolor(longCondition?color.yellow:na)
strategy.entry("RSI_V_LE", strategy.long, when=longCondition )
//stoploss value at 10%
stopLossValue=strategy.position_avg_price -  (strategy.position_avg_price*stopLoss/100) 
//stopLossValue=valuewhen(longCondition,low,3)


//takeprofit at RSI highest  reading
//at RSI75 move the stopLoss to entry price
moveStopLossUp=strategy.position_size>0 and crossunder(myRsi,70)
barcolor(moveStopLossUp?color.blue:na)
stopLossValue:=crossover(myRsi,70) ? strategy.position_avg_price:stopLossValue

//stopLossValue:=moveStopLossUp?strategy.position_avg_price:stopLossValue
rsiPlotColor=longCondition ?color.yellow:color.purple
rsiPlotColor:= moveStopLossUp ?color.blue:rsiPlotColor
plot(myRsi, title="RSI", linewidth=2, color=rsiPlotColor)
//longCondition?color.yellow:#8D1699)
hline(50, title="Middle Line", linestyle=hline.style_dotted)
obLevel = hline(75, title="Overbought", linestyle=hline.style_dotted)
osLevel = hline(25, title="Oversold", linestyle=hline.style_dotted)
fill(obLevel, osLevel, title="Background", color=#9915FF, transp=90)


    
//when RSI crossing down 70 , close 1/2 position and move stop loss to average entry price
strategy.close("RSI_V_LE",  qty=strategy.position_size*1/2, when=strategy.position_size>0 and crossunder(myRsi,70))

//when RSI reaches high reading 90 and crossing down close 3/4 position
strategy.close("RSI_V_LE",  qty=strategy.position_size*3/4, when=strategy.position_size>0 and crossunder(myRsi,90))



//close everything when Rsi goes down below to 10 or stoploss hit  
//just keeping RSI cross below 10 , can work as stop loss , which also keeps you long in the trade ... however sharp declines could  make large loss
//so I combine RSI goes below 10 OR stoploss hit  , whichever comes first - whole posiition closed
longCloseCondition=crossunder(myRsi,10)  or close<stopLossValue
strategy.close("RSI_V_LE", qty=strategy.position_size,when=longCloseCondition )



Thêm nữa