RSIとフィボナッチリトレースメント取引戦略

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

img

概要

この記事では,主に相対強度指数 (RSI) とフィボナッチリトレースメントレベルを組み合わせた取引戦略について説明します.この戦略は,最初に特定の期間の歴史的な価格動態に基づいてキーフィボナッチリトレースメントレベルを計算し,その後,RSIインジケーターを使用して,市場がリトレースメントレベル近くで過買いまたは過売れているかどうかを判断し,取引信号を生成します.

戦略原則

この戦略の基本原則は以下のとおりです.

  1. 特定の期間の価格データ (例えば200バー) を用いて,その期間の価格の中間値,標準偏差,キーフィボナッチリトレースメントレベル (例えば0.764) を計算する.

  2. 価格が上位または下位リトラセーションレベルに近づくと,RSI指標を使用して,これらのレベル周辺に過買いまたは過売状態があるかどうかを判断します.

  3. RSIインジケーターが過剰購入または過剰売却のシグナルを示す場合,リトレースメントレベル周辺で長または短シグナルが生成されます.

  4. 価格が既定レベルを超えたり,ストップ・ロスが起動したときに,ストップ・ロスを設定し,プロフィートを取ってポジションを閉じます.

上記は,この戦略における取引機会を特定するための基本作業です.

利点分析

RSI や フィボナッチ の 単独 の 使用 と 比べ て,この 組み合わせ の 戦略 は 次 の 利点 を 持っ て い ます.

  1. 二重インジケーターフィルタリングにより 偽信号が減少し 信号の質が向上します

  2. フィボナッチリトレースメントレベルでの取引は典型的な技術分析技術です.

  3. ストップ・ロストとテイク・プロフィートのペースで,取引あたりの最大損失は効果的に制御できます.

  4. パラメータは,異なる期間や製品に最適化できます.

リスク分析

この戦略には注意すべきリスクもあります.

  1. キーレベルでの逆転の確率は100%ではない.価格動向と組み合わせなければならない.

  2. 単期RSIは死猫の跳びから偽信号を生む可能性があります. 複数のタイムフレームの検証を検討してください.

  3. 緩やかなストップ損失設定は損失を増やす可能性があります.

  4. 価格変動の際にストップが実行される可能性があります.より広範なストップを検討する必要があります.

パラメータ調整や指標の組み合わせの最適化などによって これらのリスクは管理できます

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

さらに最適化すべき分野は以下の通りである.

  1. 低音量で誤ったブレイクを避けるため,音量指示器を追加します.

  2. バンドブレイクからの信号としてボリンジャーバンドを考慮します.

  3. 高品質の取引機会を自動的に検出するための機械学習モデルを構築する.

  4. 自動パラメータ調整とストップ損失/利益レベル調整のための遺伝子アルゴリズムを使用します.

概要

この記事では,RSIとフィボナッチリトラセメント分析を組み合わせた定量的な取引戦略を詳細に説明します. 双指数分析と古典的な技術戦略を組み合わせることで,戦略は管理されたリスクの下で信号品質を改善します. 継続的なパラメータチューニングとモデル最適化によってさらなるパフォーマンス向上を達成することができます.


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

//@version=4
strategy(title="Gab Fib  + RSI", overlay=true, default_qty_type=strategy.cash, default_qty_value=100000, initial_capital=1000, currency=currency.USD, commission_type=strategy.commission.cash_per_order, commission_value=4)

// Inputs
timeFilter = year >= 2000
    // Stop Loss 
stop_loss = input(title="SL in % of Instrum. i.e 1.5%=150pips", minval=0, step=0.1, defval=1.5) /100
    // RSI Inputs
len = input(title="[RSI] Length", minval=0, step=1, defval=14)
overSold = input(title="[RSI] Over Sold %", defval=30)
overBought = input(title="[RSI] Over Bought %", defval=70)
    // Fibonacci Levels
length = input(title="[Fibonacci] Length", defval=200, minval=1)
src = input(hlc3, title="[Fibonacci] Source")
mult = input(title="[Fibonacci] Multiplier", defval=3.0, minval=0.001, maxval=50)
level = input(title="[Fibonacci] Level", defval=764)


// Calculate Fibonacci
basis = vwma(src, length)
dev = mult * stdev(src, length)
fu764= basis + (0.001*level*dev)
fu1= basis + (1*dev)
fd764= basis - (0.001*level*dev)
fd1= basis - (1*dev)

// Calculate RSI
vrsi = rsi(close, len)

// Calculate the Targets
targetUp = fd764
targetDown = fu764
    // Actual Targets
bought = strategy.position_size[0] > strategy.position_size[1]
exit_long = valuewhen(bought, targetUp, 0)
sold = strategy.position_size[0] < strategy.position_size[1]
exit_short = valuewhen(sold, targetDown, 0)

// Calculate Stop Losses
sl_long = close * (1-stop_loss)
sl_short = close * (1+stop_loss)


// Conditions to Open Trades
openLong = low < fd1 and crossover(vrsi[1], overSold)
openShort = high > fu1 and crossunder(vrsi[1], overBought)

// Conditions to Close Trades
closeLong = high > exit_long or sl_long
closeShort = low < exit_short or sl_short


//Rounding to MinTick value
roundtargetUp = round_to_mintick(targetUp)
roundtargetDown = round_to_mintick(targetDown)
roundsllong = round_to_mintick(sl_long)
roundslshort = round_to_mintick(sl_short)

// Plots
plot(basis, color=color.blue, linewidth=2, title="[Fibonacci Level] Basis")
plot(fu764, color=color.white, linewidth=1, title="[Fibonacci Level] Short Target")
plot(fu1, color=color.red, linewidth=2, title="[Fibonacci Level] Top")
plot(fd764, color=color.white, linewidth=1, title="[Fibonacci Level] Long Target")
plot(fd1, color=color.green, linewidth=2, title="[Fibonacci Level] Bottom")


// Strategy Orders
if timeFilter
    // Entry Orders
    strategy.entry(id="buy", long=true, when=openLong and high < targetUp, limit=close, alert_message="buy,"+tostring(syminfo.ticker)+",tp="+tostring(roundtargetUp)+",sl="+tostring(roundsllong))
    strategy.entry(id="sell", long=false, when=openShort and low > targetDown, limit=close,  alert_message="sell,"+tostring(syminfo.ticker)+",tp="+tostring(roundtargetDown)+",sl="+tostring(roundslshort))

    // Exit Orders
    strategy.exit(id="closelong", when=closeLong and strategy.position_size > 0, limit=exit_long, stop=sl_long, alert_message="closelong,"+tostring(syminfo.ticker))
    strategy.exit(id="closeshort", when=closeShort and strategy.position_size < 0, limit=exit_short, stop=sl_short, alert_message="closeshort,"+tostring(syminfo.ticker))

もっと