RSI W 패턴 돌파 전략


생성 날짜: 2023-09-17 18:24:17 마지막으로 수정됨: 2023-09-17 18:24:17
복사: 0 클릭수: 879
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

개요

이 전략은 RSI 지표의 W 형태를 식별하여, 트렌드 판단 조건과 결합하여, 낮은 가격과 높은 가격의 돌파구를 수행합니다. 일반적인 RSI 과잉 구매 과잉 판매 영역 판단에 비해, W 형태를 식별하는 것이 구매 시점을 더 명확하게 결정합니다.

전략 원칙

  1. RSI ((5) 를 사용하여 W 형태를 판단하여 잠재적인 구매 기회를 찾습니다. W 형태가 과매도 영역에 나타나면 다가오는 반전을 예고합니다.

  2. EMA20에서 EMA50를 착용하는 것은 트렌드 상행, 입구의 큰 방향 판단이다.

  3. W 형태를 인식하고 상승 추세에 있을 때 구매한다.

  4. RSI가 다시 20로 떨어질 때, 이미 지분을 가지고 있다면, 지분을 올릴 수 있다.

  5. RSI가 75을 넘으면, 오버 바이 영역을 나타내고, 스톱이 탈퇴한다.

  6. 8%의 중지 지점을 설정하고, 손실이 그 지점을 초과하면 중지 탈퇴를 한다.

우위 분석

  1. W 형식 인식은 입학의 확실성을 증가시킵니다.

  2. 트렌드를 통해 필터링 신호의 무효성을 판단하여 역전 기회를 놓치지 않도록하십시오.

  3. RSI 파라미터는 5일간 단선 기회를 잡을 수 있는 시간으로 설정된다.

  4. 스톱포드 (Stop Stop Loss) 를 설정하여 위험을 조절할 수 있습니다.

위험 분석

  1. W 형태 인식은 파라미터 설정에 의존하여 형태를 잘못 인식하거나 잘못 판단할 수 있다.

  2. “이런 일이 벌어진다면, 우리는 더 이상 ‘미국’에 머물지 않을 것입니다”.

  3. RSI는 가짜 돌파구를 발생하기 쉽기 때문에 적절한 필터링을 해야 한다.

  4. 너무 큰 스톱포인트를 설정하면 너무 일찍 스톱포인트를 설정할 수 있습니다.

최적화 방향

  1. 다양한 RSI 주기 변수를 테스트하여 최적의 변수 조합을 찾습니다.

  2. 형상 결정 조건을 증가시키고, 식별 정확도를 높인다.

  3. 다른 지표와 결합하여 신호를 필터링하여 잘못된 거래를 줄여줍니다.

  4. 동적으로 스톱 포지션을 조정하고 스톱 전략을 최적화한다.

  5. 투자금지 전략의 최적화, 수익을 보장하는 조건에서 지분 기간을 연장한다.

요약하다

이 전략은 RSI W 형태를 활용하여 효율적인 반전 돌파 작업을 수행한다. 그러나 추가로 최적화 파라미터 설정이 필요하며, 다른 기술 지표와 함께 신호 필터링을 수행하여 전략의 안정성과 수익률을 높인다.

전략 소스 코드
/*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 )