高度なトレンドフォローと適応型トレーリングストップ戦略

ATR SL TS
作成日: 2024-12-20 14:12:05 最終変更日: 2024-12-20 14:12:05
コピー: 1 クリック数: 418
1
フォロー
1617
フォロワー

高度なトレンドフォローと適応型トレーリングストップ戦略

概要

これは,Supertrend指数に基づくトレンド追跡戦略で,自己適応の追跡ストップメカニズムを組み合わせている.この戦略は,主にSupertrend指数によって市場のトレンド方向を識別し,リスク管理と出場時間を最適化するために動的調整の追跡ストップを使用する.この戦略は,パーセントストップ,ATRストップ,固定ポイントストップを含む複数のストップ方法をサポートし,異なる市場環境に応じて柔軟に調整することができる.

戦略原則

戦略の中核となるロジックは、次の主要な要素に基づいています。

  1. Supertrend指標をトレンド判断の主要な根拠として使用し,ATR (平均リアル波幅) と組み合わせて市場の変動性を測定する
  2. 入場シグナルは,スーパートレンドの方向変化によって引き起こされ,多,空,または双方向取引をサポートします.
  3. ストップメカニズムは,市場波動に応じて自動的にストップ位置を調整できる自己適応的なトラッキングストップを採用しています.
  4. 取引管理システムにはポジション管理 (アカウントの15%のポジションをデフォルト) と時間フィルタリングの仕組みが含まれています.

戦略的優位性

  1. トレンドキャプター:スーパートレンド指標により,主要なトレンドを効果的に識別し,誤判を減らす
  2. リスク管理の完善: 多種多様な止損メカニズムにより,異なる市場環境に対応できる
  3. 柔軟性:複数の取引方向とストップモードをサポートする配置
  4. 適応性:トラッキングストップは市場の変動に合わせて自動的に調整され,戦略の適応性を高めます.
  5. 完全な反復システム: タイムフィルター機能が組み込まれ,履歴の分析が容易になります.

戦略リスク

  1. トレンド反転のリスク:波動の激しい市場では誤った信号が出る可能性がある
  2. スライドポイントリスク:市場流動性の影響によるストップ・トラックの実行
  3. パラメータ感性:スーパートレンドの要因とATR周期の設定が戦略のパフォーマンスに大きく影響する
  4. 市場環境依存: 変動する市場での取引の頻度がコストを増加させる可能性がある

戦略最適化の方向性

  1. 信号フィルタリングの最適化: 偽信号をフィルタリングするために追加の技術指標を追加できます.
  2. ポジション管理の最適化:市場の波動的な動向に応じてポジション保持比率を調整できる
  3. 損失防止機構の強化:コスト平均設計により複雑な損失防止論理を組み込むことができる
  4. 入場時の最適化:入場の精度を高めるために,価格構造分析を追加できます.
  5. 改善されたフィードバックシステム: 戦略のパフォーマンスを評価するためのより多くの指標を追加できます.

要約する

これは,合理的でリスクが制御可能なトレンド追跡戦略である.Supertrend指標と柔軟な止損機構を組み合わせることで,戦略は,高い収益性を維持しながら,リスクを効果的に制御することができる.戦略は,異なる市場環境で使用するのに適した配置性が強く,十分なパラメータの最適化と裏付けが必要である.将来的には,より多くの技術分析ツールとリスク制御手段を追加することで,戦略の安定性と収益性をさらに向上させることができる.

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

//@version=6
strategy("Supertrend Strategy with Adjustable Trailing Stop [Bips]", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=15)

// Inputs
atrPeriod = input(10, "ATR Länge", "Average True Range „wahre durchschnittliche Schwankungsbreite“ und stammt aus der technischen Analyse. Die ATR misst die Volatilität eines Instruments oder eines Marktes. Mit ihr kann die Wahrscheinlichkeit für einen Trendwechsel bestimmt werden.", group="Supertrend Settings")
factor = input.float(3.0, "Faktor", step=0.1, group="Supertrend Settings")
tradeDirection = input.string("Long", "Trade Direction", options=["Both", "Long", "Short"], group="Supertrend Settings")
sl_type    = input.string("%", "SL Type", options=["%", "ATR", "Absolute"])
// Parameter für ST nur für einstieg -> Beim Ausstieg fragen ob der bool WWert true ist -> Für weniger und längere Trädes 

sl_perc    = input.float(4.0, "% SL", group="Stop Loss Einstellung")
atr_length = input.int(10, "ATR Length", group="Stop Loss Einstellung")
atr_mult   = input.float(2.0, "ATR Mult", group="Stop Loss Einstellung")
sl_absol   = input.float(10.0, "Absolute SL", group="Stop Loss Einstellung")

//-------------------------//
// BACKTESTING RANGE
fromDay   = input.int(defval=1, title="From Day", minval=1, maxval=31, group="Backtesting Einstellung")
fromMonth = input.int(defval=1, title="From Month", minval=1, maxval=12, group="Backtesting Einstellung")
fromYear  = input.int(defval=2016, title="From Year", minval=1970, group="Backtesting Einstellung")
toDay     = input.int(defval=1, title="To Day", minval=1, maxval=31, group="Backtesting Einstellung")
toMonth   = input.int(defval=1, title="To Month", minval=1, maxval=12, group="Backtesting Einstellung")
toYear    = input.int(defval=2100, title="To Year", minval=1970, group="Backtesting Einstellung")

startDate  = timestamp(fromYear, fromMonth, fromDay, 00, 00)
finishDate = timestamp(toYear, toMonth, toDay, 00, 00)
time_cond  = time >= startDate and time <= finishDate

//-------------------------//
// Supertrend calculation
[_, direction] = ta.supertrend(factor, atrPeriod)

// SL values
sl_val = sl_type == "ATR"      ? atr_mult * ta.atr(atr_length) : 
         sl_type == "Absolute" ? sl_absol : 
         close * sl_perc / 100
         
// Init Variables
var pos         = 0
var float trailing_sl = 0.0

// Signals
long_signal  = nz(pos[1]) !=  1 and high > nz(trailing_sl[1])
short_signal = nz(pos[1]) != -1 and low  < nz(trailing_sl[1]) 

// Calculate SL
trailing_sl := short_signal     ? high + sl_val : 
               long_signal      ? low  - sl_val : 
               nz(pos[1]) ==  1 ? math.max(low  - sl_val, nz(trailing_sl[1])) :  
               nz(pos[1]) == -1 ? math.min(high + sl_val, nz(trailing_sl[1])) : 
               nz(trailing_sl[1])
               
// Position var               
pos := long_signal  ? 1 : short_signal ? -1 : nz(pos[1]) 

// Entry logic
if ta.change(direction) < 0 and time_cond
    if tradeDirection == "Both" or tradeDirection == "Long"
        strategy.entry("Long", strategy.long, stop=trailing_sl)
    else
        strategy.close_all("Stop Short")

if ta.change(direction) > 0 and time_cond
    if tradeDirection == "Both" or tradeDirection == "Short"
        strategy.entry("Short", strategy.short, stop=trailing_sl)
    else
        strategy.close_all("Stop Long")

// Exit logic: Trailing Stop and Supertrend
//if strategy.position_size > 0 and not na(trailing_sl)
    //strategy.exit("SL-Exit Long", from_entry="Long", stop=trailing_sl)

//if strategy.position_size < 0 and not na(trailing_sl)
    //strategy.exit("SL-Exit Short", from_entry="Short", stop=trailing_sl)

// Trailing Stop visualization
plot(trailing_sl, linewidth = 2, color = pos == 1 ? color.green : color.red)
//plot(not na(trailing_sl) ? trailing_sl : na, color=pos == 1 ? color.green : color.red, linewidth=2, title="Trailing Stop")