RSIとボリンジャー帯の二重戦略

作者: リン・ハーンチャオチャン, 日付: 2023-12-12 11:53:49
タグ:

img

概要

この戦略の主なアイデアは,相対強度指数 (RSI) とボリンジャー帯 (Bollinger Bands) を組み合わせ,二重取引信号をフィルターし,偽信号からの干渉をできるだけ最小限に抑え,信号品質を改善することです.

RSI インディケーターは,価格がボリンジャーバンドの上下線を突破または引き戻す間,過剰購入または過剰売却のシグナルを示すとき,取引の機会が現れる.それは2つの異なるインディケーターの利点を組み合わせ,市場変動の統計的特徴と市場参加者の長/短姿勢の両方を考慮し,包括的な判断の基盤を形成します.

戦略原則

RSIの部分では,異なるサイクルの長さの2つのRSIインジケーターを同時にモニターします.短いサイクルのインジケーターは過買い・過売のシグナルを捉えるのに使用され,長いサイクルのインジケーターはトレンド逆転を確認するために使用されます.短サイクルRSIが過買い/過売を示し,長いサイクルRSIが逆転を示すると,取引機会が形成されたと考えています.

ボリンジャーバンドの部分では,価格が上下線を突破するかどうかを監視します. ボリンジャーバンドの上下線を突破することは販売ポイントであり,下下線を突破することは購入ポイントです. 同時に,価格がボリンジャーバンドに引き戻されるかどうかを監視します. これにより,逆転の機会を間に合うように把握できます.

RSIとボリンジャー・バンドの信号が同時に現れると 取引機会が形成され 取引命令が発行されると考えます

利点分析

  • 二重指標フィルタリングにより信頼性が高く,不必要な取引は避けられます
  • トレンドと逆転の市場段階の両方で機会を把握する
  • 必要に応じて調整可能な設定のための設定可能なパラメータ
  • 組み込み時間とお金の管理

リスク分析

  • 誤ったボリンジャー・バンドパラメータ設定は,誤った信号を引き起こす可能性があります.
  • 市場が極端に変動する状況に対応できない
  • RSIの差異は誤った信号を生む可能性があります.
  • 異なる製品とサイクルに適応するために必要なパラメータ最適化

パラメータの最適化,適切な位置削減,手動介入などによってリスクを回避し制御できます

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

  • RSI パラメータを調整し,過買い/過売り判断を最適化
  • ブレイクアウト戦略を最適化するためにボリンジャーバンドの幅を調整する
  • ポジション管理メカニズムを追加する
  • ストップ損失戦略を追加
  • 多要素モデルを構築するためにより多くの指標を組み込む

結論

RSIとボリンジャーバンドの二重戦略は,高品質のシグナルを生成するために,2つの指標の強みを完全に活用する.適切なパラメータ最適化とリスク管理により,安定した投資収益を達成することができる.より多くのシグナルとモデルを組み込むことも将来の方向性である.


/*backtest
start: 2023-11-11 00:00:00
end: 2023-12-04 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy("Ezieh Str.v2", shorttitle="Ezieh Str.v2", overlay=true, pyramiding=10, currency=currency.USD, slippage=3, commission_type=strategy.commission.cash_per_order, commission_value=0.04, initial_capital=1000)



UseDateFilter  = input(title="Enable Date Filter"         ,type=input.bool    ,defval=false                               ,group="Date & Time" ,tooltip="Turns on/off date filter")
StartDate      = input(title="Start Date Filter"          ,type=input.time    ,defval=timestamp("1 Jan 2000 00:00 +0000") ,group="Date & Time" ,tooltip="Date & time to start excluding trades")
EndDate        = input(title="End Date Filter"            ,type=input.time    ,defval=timestamp("1 Jan 2100 00:00 +0000") ,group="Date & Time" ,tooltip="Date & time to stop excluding trades")
UseTimeFilter  = input(title="Enable Time Session Filter" ,type=input.bool    ,defval=false                               ,group="Date & Time" ,tooltip="Turns on/off time session filter")
TradingSession = input(title="Trading Session"            ,type=input.session ,defval="1000-2200:1234567"                 ,group="Date & Time" ,tooltip="No trades will be taken outside of this range")

In(t)      => na(time(timeframe.period, t)) == false
TimeFilter = (UseTimeFilter and not In(TradingSession)) or not UseTimeFilter
DateFilter = time >= StartDate and time <= EndDate

DateTime = (UseDateFilter ? not DateFilter : true) and (UseTimeFilter ? In(TradingSession) : true) 

///////////// RSI
L_RSI_Length     = input(7  , title="L_Length")
L_RSI_OverSold   = input(45 , title="L_OverSold")
S_RSI_Length     = input(14 , title="S_Length")
S_RSI_OverBought = input(65 , title="S_OverBought")

price = close
Lvrsi = rsi(price, L_RSI_Length)
Svrsi = rsi(price, S_RSI_Length)

///////////// Bollinger Bands
BBlength = input(title="Bollinger Period Length", type=input.integer, defval=100, minval=2)
BBmult = 2.1 // input(2.0, minval=0.001, maxval=50,title="Bollinger Bands Standard Deviation")
BBbasis = sma(price, BBlength)
BBdev = BBmult * stdev(price, BBlength)
BBupper = BBbasis + BBdev
BBlower = BBbasis - BBdev
source = close
plot(BBbasis, color=color.aqua,title="Bollinger Bands SMA Basis Line")
p1 = plot(BBupper, color=color.silver,title="Bollinger Bands Upper Line")
p2 = plot(BBlower, color=color.silver,title="Bollinger Bands Lower Line")
fill(p1, p2)


///////////// Colors
switch1=input(true, title="Enable Bar Color?")
switch2=input(true, title="Enable Background Color?")



///////////// Condition
LongCondition  = crossover(Lvrsi, L_RSI_OverSold)    and crossover(close  ,BBlower)
ShortCondition = crossunder(Svrsi, S_RSI_OverBought) and crossunder(close,BBupper)
Longexcon      = crossunder(low, BBupper)
Shortexcon     = crossover(low, BBlower)

qt = round(strategy.equity/price, 3)

///////////// RSI + Bollinger Bands Strategy
if (not na(Lvrsi))

    if LongCondition and DateTime
        strategy.entry("RSI_BB_L", strategy.long, qty=qt,  comment="Long")
    else
        strategy.cancel(id="RSI_BB_L")
        
    if Longexcon
        strategy.close("RSI_BB_L", qty_percent = 100, comment = "L_exit")
    
    if ShortCondition and DateTime
        strategy.entry("RSI_BB_S", strategy.short, qty=qt,  comment="Short")
    else
        strategy.cancel(id="RSI_BB_S")
        
    if Shortexcon
        strategy.close("RSI_BB_S", qty_percent = 100, comment = "S_exit")
    
//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)

もっと