RSI W パターン ブレイクストラテジー

作者: リン・ハーンチャオチャン, 日付: 2023-09-17 18:24:17
タグ:

概要

この戦略は,RSIインジケーターのWパターンをトレンド条件と組み合わせて低買い高売りブレイクアウト操作を実行します.過剰購入/過剰販売レベルと比較して,Wパターンの識別は,より明確な購入信号のタイミングを提供します.

戦略の論理

  1. 潜在的購入機会を特定するために,RSI ((5) を用いてWパターンを特定する.過売れ地帯に現れるWパターンは,差し迫った逆転を示します.

  2. EMA20が EMA50を横切ると上昇傾向が決定し,方向性バイアスが発生します.

  3. Wパターンが確認され トレンドが上昇すると ロングオーダーが起動します

  4. すでにポジションにある場合,RSIが再び20を下回る場合は追加買いが許されます.

  5. RSIが75を超えると 買い過ぎの状況を示し 利益引き上げが開始されます

  6. 8%のストップ・ロスは設定されます. ストップ・ロスはこの値を超えると,ストップ・ロスは実行されます.

利点分析

  1. Wパターンの識別は入力の確実性を高めます

  2. トレンドフィルターと組み合わせると 誤った信号や逆転の機会を逃すことが 避けられます

  3. 短期的な機会を適時に把握できる.

  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 )



もっと