RSI V型パターンスウィング・トレード戦略

作者: リン・ハーンチャオチャン開催日:2024年01月12日 13:52:55
タグ:

img

概要

この戦略は,信頼性の高い短期間の収益性の高い取引戦略を開発するために,RSI指標によって形成されたV形のパターンとEMAフィルタを組み合わせ,RSIのV形のシグナルを通して正確にロングをすることで,価格が過剰に売れるときのリバウンド機会を捕捉し,短期的に利益を得ることを目的としています.

戦略の論理

  1. 長期上昇傾向を判断するために,50日間のEMAを上回る20日間のEMAを使用する.
  2. RSI は V 形 の パターン を 形成 し,過剰 に 売れた リバウンド の 機会 を 示す
    • 前回のバーの低値は前回の2バーの低値より低い
    • 現在のバーのRSIは前2バーのRSIより高い
  3. RSIは30を超えて,V型パターンの完了信号としてロングに行く.
  4. 入場価格より8%低いストップ損失を設定する
  5. RSIが70を突破すると,ポジションを閉じ,ストップロスをエントリー価格に移動します.
  6. RSIが90を超えると,3/4のポジションを閉じる
  7. RSIが10を下回ると/ストップ・ロスは引き起こす,すべてのポジションを閉じる.

利点分析

  1. 市場全体の方向性を判断するためにEMAを使用し,トレンドに反する取引を避ける
  2. RSI V型パターンは,過売りの場合,平均を逆転させる機会を捉える.
  3. リスク管理のための多重ストップ損失メカニズム

リスク分析

  1. 強烈な下落傾向は止められない損失を招く可能性があります
  2. RSI V 形信号は誤った信号を与え,不必要な損失につながる可能性があります.

オプティマイゼーションの方向性

  1. より信頼性の高いV型パターンを見つけるためにRSIパラメータを最適化
  2. 逆転信号の信頼性を高めるために他の指標を組み込む
  3. ストップ・ロスの戦略を精査し,過剰な攻撃性を防ぐこととタイムリーなストップ・ロスのバランス

概要

この戦略は,EMAフィルターとRSIV形パターン判断を統合して信頼性の高い短期取引戦略を形成する.過売れるときのリバウンド機会を効果的に把握することができます.パラメータとモデルを継続的に最適化し,ストップロスのメカニズムを改善することで,この戦略は安定性と収益性をさらに向上させることができます.量子トレーダーにとって収益性の高いスウィング取引の扉を開きます.


/*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 )



もっと