Chiến lược phá vỡ mô hình RSI W


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

Tổng quan

Chiến lược này thực hiện các hoạt động đột phá mua bán cao bằng cách xác định hình dạng W trên chỉ số RSI, kết hợp với các điều kiện phán đoán xu hướng. So với phán đoán khu vực mua bán cao của RSI thông thường, việc xác định hình dạng W có thể xác định rõ hơn thời điểm mua.

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

  1. Sử dụng RSI ((5) để đánh giá hình dạng W và tìm cơ hội mua tiềm năng. Khi hình dạng W xuất hiện trong khu vực bán tháo, nó cho thấy sự đảo ngược sắp tới.

  2. EMA20 mặc EMA50 phán quyết là xu hướng đi lên, như là hướng lớn vào phán quyết.

  3. Khi nhận ra hình dạng W và xu hướng tăng, hãy mua.

  4. Nếu bạn đã giữ vị thế, bạn có thể tăng vị thế khi RSI giảm xuống còn 20 một lần nữa.

  5. Khi RSI vượt qua 75, biểu thị vùng quá mua, thực hiện dừng rút ra.

  6. Thiết lập điểm dừng lỗ 8% và thực hiện dừng lỗ nếu lỗ vượt quá điểm đó.

Phân tích lợi thế

  1. Nhận dạng hình dạng W giúp tăng độ chắc chắn về việc nhập học.

  2. Kết hợp các xu hướng để đánh giá các tín hiệu không có hiệu quả và tránh bỏ lỡ cơ hội đảo ngược.

  3. RSI được thiết lập để nắm bắt cơ hội ngắn trong 5 ngày.

  4. Thiết lập điểm dừng để kiểm soát rủi ro.

Phân tích rủi ro

  1. Nhận dạng hình dạng W phụ thuộc vào cài đặt tham số, có thể bị bỏ qua hoặc đánh giá sai hình dạng.

  2. Một tín hiệu khác là có nguy cơ bị mắc kẹt.

  3. RSI dễ bị phá vỡ giả, nên lọc các tín hiệu thích hợp.

  4. Nếu thiết lập điểm dừng quá lớn, bạn có thể dừng quá sớm.

Hướng tối ưu hóa

  1. Kiểm tra các tham số khác nhau của chu kỳ RSI để tìm ra sự kết hợp tham số tối ưu.

  2. Thêm các điều kiện định hình để tăng độ chính xác nhận dạng.

  3. Các chỉ số khác được kết hợp để lọc tín hiệu, giảm giao dịch sai.

  4. Động thái điều chỉnh vị trí dừng lỗ, tối ưu hóa chiến lược dừng lỗ.

  5. Tối ưu hóa chiến lược dừng chân, kéo dài thời gian giữ vị trí với điều kiện đảm bảo lợi nhuận.

Tóm tắt

Chiến lược này sử dụng hình thức RSI W để thực hiện các hoạt động phá vỡ đảo ngược hiệu quả. Tuy nhiên, cần thiết phải tối ưu hóa thêm các tham số thiết lập và lọc tín hiệu với các chỉ số kỹ thuật khác để nâng cao tính ổn định và lợi nhuận của chiến lược.

Mã nguồn chiến lược
/*backtest
start: 2023-08-17 00:00:00
end: 2023-09-16 00:00:00
period: 3h
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(title="RSI W Pattern strategy", pyramiding=2, shorttitle="RSI W Pattern", overlay = false)

//Strategy Rules
//ema20 is above ema50
//RSI5 making W pattern in oversold area  or just below 70 level  , you can define the value for parameter buyRsiEntry --- dont go beyond 70
//Exit when RSI reaches 75 

len = input(title="RSI Period", minval=1, defval=5)
buyRsiEntry = input(title="look for W pattern bottom edges well below RSI level (BUY) ", minval=10, defval=65, maxval=70)
//numberOfBars = input(title="Number of Bars in W pattern ", minval=4, defval=4, maxval=6)

emaL = input(title="Long Term EMA", minval=1, defval=50, maxval=200)
emaS = input(title="Short Term EMA", minval=1, defval=20, maxval=200)

stopLoss = input(title="Stop Loss %", minval=1, defval=8, maxval=10)

//rsiWp1=false

myRsi = rsi(close,len)

//longEmaVal=ema(close,emaL)
//shortEmaVal=ema(close,emaS)

entryEma=ema(close,5)  // This is used as filetr for BUY


isEma20AboveEma50=ema(close,emaS)>ema(close,emaL) ? true : false 

//W Pattern
//rsiWp1 =  myRsi>myRsi[1] and myRsi>=30 and myRsi[1]<myRsi[2] and myRsi[2]>myRsi[3]  and myRsi[3]<myRsi[4] //This is published one
rsiWp1 =    myRsi>myRsi[1] and myRsi>=30 and myRsi[1]<myRsi[2] and myRsi[2]>myRsi[3]  and myRsi[3]<myRsi[4] and (low[1]<=low[4] or low[3]<=low[4] ) // looking for recent low

//rsiWp1 =  myRsi>myRsi[1] and myRsi>=30 and myRsi[1]<myRsi[2] and myRsi[2]>myRsi[3]  and myRsi[3]<myRsi[4]  //Ths one has 92% win rate and 4.593 prfit factor

//long condition filters
//1. ema20 > ema50
//2. Rsi5 has W pattern
//3. current RSI <= 65 (parameter buyRsiEntry)  (dont go beyond 70 , becuase that is already overbought area)
//4. current price low/close is below 5 ema --- looking for pullback  -- Optional
longCondition =  isEma20AboveEma50 and rsiWp1   and (myRsi<=buyRsiEntry  and myRsi>=30)  
//and (low<entryEma or close<entryEma)  --- if this optional required , add it to above condition

patternText=" W "

barcolor(longCondition?color.yellow:na)

//initial entry
strategy.entry("RSI_W_LE", comment="Buy" , long=true, when=longCondition  )

//legging in to existing 
strategy.entry("RSI_W_LE",comment="Add", long=true, when=strategy.position_size>0 and crossover(myRsi,10 ))

//calculate stoploss value
stopLossValue=strategy.position_avg_price -  (strategy.position_avg_price*stopLoss/100) 


rsiPlotColor=longCondition ?color.yellow:color.purple


plot(myRsi, title="RSI", linewidth=2, color=color.purple)
//    plot(myRsi, title="RSI", linewidth=2, color=rsiWp1?color.yellow:color.purple)
    //plot(myRsi[1], title="RSI", linewidth=2, color=rsiWp1==true?color.yellow:color.purple)
    //plot(myRsi[2], title="RSI", linewidth=2, color=rsiWp1?color.yellow:color.purple)
    //plot(myRsi[3], title="RSI", linewidth=2, color=rsiWp1?color.yellow:color.purple)
    //plot(myRsi[4], title="RSI", linewidth=2, color=rsiWp1?color.yellow:color.purple)
    


hline(40, title="Middle Line", color=color.blue, linestyle=hline.style_dashed)
obLevel = hline(75, title="Overbought", color=color.red, linestyle=hline.style_dashed)
osLevel = hline(30, title="Oversold", color=color.purple, linestyle=hline.style_dashed)
fill(obLevel, osLevel, title="Background", color=#9915FF, transp=90)


plotshape(
	 longCondition ? myRsi[1] : na,
	 offset=-1,
	 title="W Pattern",
	 text=patternText,
	 style=shape.labelup,
	 location=location.absolute,
	 color=color.purple,
	 textcolor=color.yellow,
	 transp=0
	 )	 
	 
bgcolor(strategy.position_size>0?color.green:na, transp=40, title='In Long Position')

//take profit or close when RSI reaches 75    
takeProfit=crossover(myRsi,75)

//close when RSi reaches profit level 
strategy.close("RSI_W_LE", comment="TP Exit", qty=strategy.position_size,when=crossover(myRsi,75) and close>strategy.position_avg_price )


//close everything when stoploss hit  
longCloseCondition=close<(strategy.position_avg_price - (strategy.position_avg_price*stopLoss/100)  ) //or crossunder(myRsi,30)
strategy.close("RSI_W_LE", comment="SL Exit", qty=strategy.position_size,when=longCloseCondition )