RSI W 패턴 파업 전략

저자:차오장, 날짜: 2023-09-17 18:24:17
태그:

전반적인 설명

이 전략은 RSI 지표에 W 패턴을 추세 조건과 결합하여 낮은 구매-높은 판매 브레이크아웃 작전을 구현합니다. 과잉 구매 / 과잉 판매 수준에 비해 W 패턴 식별은 더 명확한 구매 신호 타이밍을 제공합니다.

전략 논리

  1. 잠재적인 구매 기회를 찾기 위해 RSI (RSI) 를 사용하여 W 패턴을 식별하십시오. 과판된 구역에 나타나는 W 패턴은 임박한 반전을 나타냅니다.

  2. EMA20가 EMA50를 넘으면 상승 추세를 결정하고 방향 편차를 제공합니다.

  3. W 패턴이 확인되고 트렌드가 상승하면 긴 주문이 발생합니다.

  4. 이미 포지션에 있는 경우, RSI가 다시 20 이하로 넘어가면 추가 구매가 허용됩니다.

  5. RSI가 75을 넘으면 과잉 매입 상태가 나타납니다.

  6. 8%의 스톱 로스가 설정되어 있습니다. 손실이 이 점을 초과하면 스톱 로스 출구가 트리거됩니다.

이점 분석

  1. W 패턴 식별은 출입의 확실성을 높입니다.

  2. 트렌드 필터와 결합하면 잘못된 신호와 역전 기회를 놓칠 수 없습니다.

  3. RSI (RSI) 는 단기적 기회를 적시에 포착할 수 있습니다.

  4. 이윤을 취하고 손해를 멈추는 지점은 위험을 통제하는 데 도움이 됩니다.

위험 분석

  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 )



더 많은