RSI逆転ブレイクアウト戦略

作者: リン・ハーンチャオチャン,日付: 2023年11月08日 12:11:03
タグ:

img

概要

この戦略は,相対強度指数 (RSI) 指標に基づいており,ブレイクアウト取引を行うためにRSIのオーバーバイト/オーバーセール原則を利用する.RSIがオーバーバイトの限界を超えるとロングになり,RSIがオーバーセールの限界を超えるとショートになる.これは典型的な平均逆転取引戦略である.

戦略の論理

  1. RSI指標のパラメータは,RSI期間,超買値と超売値を含むユーザー入力に基づいて設定します.

  2. RSI が値値に対する位置に基づいて,過剰購入または過剰販売領域にあるかどうかを決定する.

  3. RSIがオーバーバイト/オーバーセールゾーンから突破して対応する値線を横切ると,反対方向に取引を行う.例えば,RSIがオーバーバイトゾーンからオーバーバイトラインを突破すると,市場は逆転すると考えられ,この時点でロングに行く.RSIがオーバーバイトゾーンからオーバーセールラインを下回ると,市場は逆転すると考えられ,ここでショートに行く.

  4. 入力後,ストップ・ロスを設定し,利益ラインを取ります. SL/TPを追跡し,トリガーされたときにポジションを閉じます.

  5. この戦略は,EMAをフィルターとして使用するオプションも提供しています. RSI信号とEMA方向に対する価格ブレイクの両方が満たされた場合にのみ取引信号を取ります.

  6. また,特定の時間枠内での取引も許可します. ポジションは時間枠の終わりに閉じられます.

利点分析

  • RSIのブレイクアウト原理を活用し バックテスト結果も良好です

  • 柔軟な過剰購入/過剰販売の制限値設定は,異なる製品に適しています.

  • 選択可能な EMA フィルターは,過剰なウィップソー取引を回避します.

  • 安定性を高めるSL/TPをサポートします.

  • 不適切な期間を避けるためにタイムフレームフィルターをサポートします.

  • 双方向の価格変動を完全に利用するために,長期と短期の両方をサポートします.

リスク分析

  • RSIの差異は頻繁に行われ,RSIだけに依存すると不正確な信号が生じる可能性があります.トレンド,移動平均等との組み合わせが必要です.

  • 適切な値設定が正しくない場合,取引が頻繁すぎたり,失敗したりします.

  • SL/TPの設定が悪ければ 過度に攻撃的や過度に保守的になります

  • 誤った EMA フィルター設定は,有効な取引を逃すか,良い信号をフィルタリングする可能性があります.

リスク対策

  • RSIパラメータを異なる製品に最適化します

  • トレンド指標と組み合わせて 差異を特定します

  • SL/TPパラメータをテストして最適化します

  • EMAパラメータをテストして最適化します

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

戦略は以下の点で改善できる:

  1. RSI パラメータを最適化して,完全なバックテストを通じて,異なる製品に最適な設定を見つけます.

  2. より強力な信号を生成するために RSI を組み合わせたり,代替したりする異なる指標を試す.例えば,MACD,KD,ボリンジャー帯など.

  3. ストップ・ロスを最適化し,安定性を高めるために利益戦略を採用する.適応ストップまたはトレーリングストップを使用することができる.

  4. EMAフィルターのパラメータを最適化するか,他のフィルターで実験して,ウィップソウを避ける.

  5. トレンドフィルターモジュールを追加して,主要なトレンドに対して取引しないようにします.

  6. この戦略のための最良の取引セッションを見つけるために異なる時間枠をテストします.

概要

RSI逆転ブレイクアウト戦略は,古典的なオーバーバイト/オーバーセール原則に基づいた明確な論理を持っています.適切なリスク制御フィルターで極端に平均逆転を捉えることを目指しています.パラメータチューニングとモジュール強化を通じて安定した戦略に変える可能性が高いです.ライブ取引で最適化し適用する価値があります.


/*backtest
start: 2023-10-08 00:00:00
end: 2023-11-07 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/
// © REV0LUTI0N

//@version=4

strategy("RSI Strategy", overlay=true, initial_capital = 10000, default_qty_value = 10000, default_qty_type = strategy.cash)

// Strategy Backtesting
startDate  = input(timestamp("2021-10-01T00:00:00"), type = input.time, title='Backtesting Start Date')
finishDate = input(timestamp("9999-12-31T00:00:00"), type = input.time, title='Backtesting End Date')

time_cond  = true
// Strategy

Length = input(12, minval=1)
src = input(close, title="Source")
overbought = input(70, minval=1)
oversold = input(30, minval=1)
xRSI = rsi(src, Length)
    
rsinormal = input(true, title="Overbought Go Long & Oversold Go Short")
rsiflipped = input(false, title="Overbought Go Short & Oversold Go Long")

// EMA Filter
noemafilter = input(true, title="No EMA Filter")
useemafilter = input(false, title="Use EMA Filter")
ema_length = input(defval=15, minval=1, title="EMA Length")
emasrc = input(close, title="Source")
ema = ema(emasrc, ema_length)
plot(ema, "EMA", style=plot.style_linebr, color=#cad850, linewidth=2)

//Time Restriction Settings
startendtime = input("", title='Time Frame To Enter Trades')
enableclose = input(false, title='Enable Close Trade At End Of Time Frame')
timetobuy = (time(timeframe.period, startendtime))
timetoclose = na(time(timeframe.period, startendtime))

// Stop Loss & Take Profit % Based
enablesl = input(false, title='Enable Stop Loss')
enabletp = input(false, title='Enable Take Profit')
stopTick = input(5.0, title='Stop Loss %', type=input.float, step=0.1) / 100
takeTick = input(10.0, title='Take Profit %', type=input.float, step=0.1) / 100

longStop = strategy.position_avg_price * (1 - stopTick)
shortStop = strategy.position_avg_price * (1 + stopTick)
shortTake = strategy.position_avg_price * (1 - takeTick)
longTake = strategy.position_avg_price * (1 + takeTick)

plot(strategy.position_size > 0 and enablesl ? longStop : na, style=plot.style_linebr, color=color.red, linewidth=1, title="Long Fixed SL")
plot(strategy.position_size < 0 and enablesl ? shortStop : na, style=plot.style_linebr, color=color.red, linewidth=1, title="Short Fixed SL")
plot(strategy.position_size > 0 and enabletp ? longTake : na, style=plot.style_linebr, color=color.green, linewidth=1, title="Long Take Profit")
plot(strategy.position_size < 0 and enabletp ? shortTake : na, style=plot.style_linebr, color=color.green, linewidth=1, title="Short Take Profit")

// Alert messages
message_enterlong  = input("", title="Long Entry message")
message_entershort = input("", title="Short Entry message")
message_closelong = input("", title="Close Long message")
message_closeshort = input("", title="Close Short message")

// Strategy Execution
if (xRSI > overbought and close > ema and time_cond and timetobuy and rsinormal and useemafilter)
    strategy.entry("Long", strategy.long, alert_message = message_enterlong)
    
if (xRSI < oversold and close < ema and time_cond and timetobuy and rsinormal and useemafilter)
    strategy.entry("Short", strategy.short, alert_message = message_entershort)
    
if (xRSI < oversold and close > ema and time_cond and timetobuy and rsiflipped and useemafilter)
    strategy.entry("Long", strategy.long, alert_message = message_enterlong)
    
if (xRSI > overbought and close < ema and time_cond and timetobuy and rsiflipped and useemafilter)
    strategy.entry("Short", strategy.short, alert_message = message_entershort)
    
if (xRSI > overbought and time_cond and timetobuy and rsinormal and noemafilter)
    strategy.entry("Long", strategy.long, alert_message = message_enterlong)
    
if (xRSI < oversold and time_cond and timetobuy and rsinormal and noemafilter)
    strategy.entry("Short", strategy.short, alert_message = message_entershort)
    
if (xRSI < oversold and time_cond and timetobuy and rsiflipped and noemafilter)
    strategy.entry("Long", strategy.long, alert_message = message_enterlong)
    
if (xRSI > overbought and time_cond and timetobuy and rsiflipped and noemafilter)
    strategy.entry("Short", strategy.short, alert_message = message_entershort)
    
if strategy.position_size > 0 and timetoclose and enableclose
    strategy.close_all(alert_message = message_closelong)
if strategy.position_size < 0 and timetoclose and enableclose
    strategy.close_all(alert_message = message_closeshort)
    
if strategy.position_size > 0 and enablesl and time_cond
    strategy.exit(id="Close Long", stop=longStop, limit=longTake, alert_message = message_closelong)
if strategy.position_size < 0 and enablesl and time_cond
    strategy.exit(id="Close Short", stop=shortStop, limit=shortTake, alert_message = message_closeshort)
    
if strategy.position_size > 0 and enabletp and time_cond
    strategy.exit(id="Close Long", stop=longStop, limit=longTake, alert_message = message_closelong)
if strategy.position_size < 0 and enabletp and time_cond
    strategy.exit(id="Close Short", stop=shortStop, limit=shortTake, alert_message = message_closeshort)
    



もっと