デュアルRSI指標に基づく適応型スイングトレードシステム

RSI SL TP MM ATR RR
作成日: 2024-12-13 11:57:17 最終変更日: 2024-12-13 11:57:17
コピー: 4 クリック数: 448
1
フォロー
1617
フォロワー

デュアルRSI指標に基づく適応型スイングトレードシステム

概要

この戦略は,二重のRSI (相対的に強い指数) 指標に基づく自適化取引システムである.市場動向と取引機会を識別し,資金管理とリスク管理の仕組みを通じて取引パフォーマンスを最適化するために,異なる時間周期のRSI指標を組み合わせている.この戦略の核心は,多周期RSIの協調的な配合によって,取引の安全性を保証しながら,収益性を向上させることにある.

戦略原則

戦略は7周期RSIを主要取引信号として採用し,日経RSIをトレンドフィルターとして使用する.短期RSIが40以下から上昇し,日経RSIが55以上になると,システムは複数の信号を発信する.ポジション保持期間中に価格が最初のポジション価格より下がれば,システムは自動的にポジションを上昇させ,平均コストを下げる.RSIが60以上から下方へ突破すると,システムは平仓で利益を得る.同時に,5%の損失を制御する.戦略には,総資本と予備リスクの比率に基づいて,各取引のポジションサイズを自動的に計算する資金管理モジュールも含まれている.

戦略的優位性

  1. 多周期RSI配合により信号の信頼性が向上
  2. 適応可能な加仓メカニズムにより,保有コストを効率的に削減できます.
  3. 資金管理システムにより,リスクの好みに合わせてポジションを自動的に調整
  4. 固定ストップ・プロテクション,取引毎のリスクの厳格な管理
  5. 取引コストを考慮し,実際の取引状況に適合する

戦略リスク

  1. RSI指標は,急激な波動の市場の中で偽信号を生む可能性があります.
  2. 長期低迷の状況では,加仓制度は大きな損失を招く可能性がある.
  3. 固定パーセンテージストップは,高変動期に保守的すぎる可能性があります.
  4. 取引コストは,取引頻度で利益に大きく影響する可能性があります.
  5. 十分な流動性支援策の実施

戦略最適化の方向性

  1. 波動率指数 (ATRなど) を導入して,ストップポジションを動的に調整する
  2. トレンド強度フィルターを追加して,波動市場における偽信号を減らす
  3. 市場変動を考慮して動的な調整を行う
  4. RSI 確認シグナルを追加する
  5. 適応可能なポジション管理システムを開発

要約する

これは,技術分析とリスク管理を組み合わせた完全な取引システムである.多周期的なRSIの協同作用によって取引信号を提供し,資金管理と止損メカニズムによってリスクを制御する.この戦略は,傾向が明らかな市場で動作するのに適しているが,実際の市場状況に応じてパラメータの最適化が必要である.システムの拡張性は良好で,さらなる最適化のためのスペースが確保されている.

ストラテジーソースコード
/*backtest
start: 2024-11-12 00:00:00
end: 2024-12-11 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Dual RSI with Rebuy Logic + Capital, Commission, and Stop Loss", overlay=true)

// Parameter
rsi_length = input.int(7, title="RSI Length")
daily_rsi_length = input.int(7, title="Daily RSI Length")
capital = input.float(10000, title="Initial Capital", minval=0)  // Kapital
risk_per_trade = input.float(0.01, title="Risk per Trade (%)", minval=0.01, maxval=1.0)  // Risikogröße in Prozent
commission = input.float(0.1, title="Commission (%)", minval=0, maxval=100)  // Kommission in Prozent
stop_loss_pct = input.float(5, title="Stop Loss (%)", minval=0.1, maxval=100)  // Stop-Loss in Prozent

// Ordergröße berechnen
risk_amount = capital * risk_per_trade
order_size = risk_amount / close  // Größe der Order basierend auf Risikogröße und Preis

// Daily RSI
day_rsi = request.security(syminfo.tickerid, "D", ta.rsi(close, daily_rsi_length), lookahead=barmerge.lookahead_on)

// RSI auf aktuellem Timeframe
rsi = ta.rsi(close, rsi_length)

// Kauf- und Verkaufsbedingungen
buy_condition = rsi[1] < 40 and rsi > rsi[1] and day_rsi > 55
sell_condition = rsi[1] > 60 and rsi < rsi[1]

// Variablen, um den Preis des ersten Kaufs zu speichern
var float first_buy_price = na
var bool is_position_open = false

// Kauf-Logik
if buy_condition
    if not is_position_open
        // Initiales Kaufsignal
        strategy.entry("Buy", strategy.long, qty=1)
        first_buy_price := close
        is_position_open := true
    else if close < first_buy_price
        // Rebuy-Signal, nur wenn Preis niedriger als erster Kaufpreis
        strategy.entry("Rebuy", strategy.long, qty=1)

// Verkaufs-Logik
if sell_condition and is_position_open
    strategy.close("Buy")
    strategy.close("Rebuy")
    first_buy_price := na  // Zurücksetzen des Kaufpreises
    is_position_open := false

// Stop-Loss-Bedingung
if is_position_open
    // Stop-Loss-Preis berechnen (5% unter dem Einstiegspreis)
    stop_loss_price = first_buy_price * (1 - stop_loss_pct / 100)
    
    // Stop-Loss für "Buy" und "Rebuy" festlegen
    strategy.exit("Stop Loss Buy", from_entry="Buy", stop=stop_loss_price)
    strategy.exit("Stop Loss Rebuy", from_entry="Rebuy", stop=stop_loss_price)

// Performance-Metriken berechnen (mit Kommission)
gross_profit = strategy.netprofit / capital * 100
commission_cost = commission / 100 * strategy.closedtrades
net_profit = gross_profit - commission_cost

// Debug-Plots
plot(first_buy_price, title="First Buy Price", color=color.blue, linewidth=1)
plotchar(buy_condition, title="Buy Condition", char='B', location=location.abovebar, color=color.green)
plotchar(sell_condition, title="Sell Condition", char='S', location=location.belowbar, color=color.red)

// Debugging für Performance