ボリンジャーバンドとATRに基づくマルチレベルのインテリジェントな動的追跡ストップロス戦略

BB ATR MA SMA EMA SMMA WMA VWMA SD
作成日: 2024-12-11 14:52:24 最終変更日: 2024-12-11 14:52:24
コピー: 2 クリック数: 88
1
フォロー
1166
フォロワー

ボリンジャーバンドとATRに基づくマルチレベルのインテリジェントな動的追跡ストップロス戦略

概要

この戦略は,ブリン帯とATR指標をベースにしたインテリジェントな取引システムで,多層のストップ・ロスの仕組みを組み合わせている.戦略は,主にブリン帯下線近くの反転信号を識別して多頭入場を行い,ダイナミック・ストップ・ロスを採用してリスクを管理している.システムは,20%の利益目標と12%のストップ・ロスを設計し,ATR指標と組み合わせてダイナミック・ストップ・ロスを実現し,利益を保護しながら,トレンドに十分な発展の余地を与えることができる.

戦略原則

戦略の中核となるロジックには、次の主要な部分が含まれます。

  1. 入場条件:赤いがブリン帯下線に触れた後に緑のが現れるように要求する.この形状は通常,反転信号の可能性を示唆する.
  2. 移動平均の選択:複数の移動平均タイプ (SMA,EMA,SMMA,WMA,VWMA) をサポートし,デフォルトで20周期SMAを使用する.
  3. ブリン帯パラメータ: 1.5倍標準差を帯域として使用し,この設定は従来の2倍標準差よりも保守的です.
  4. ストップ・メカニズム: 20%の初期収益目標設定
  5. ストップ・メカニズム: 12%の固定ストップ・ポイント保護資金を設定する.
  6. ダイナミック・トラッキング・ストロー:
    • 目標利益レベルに達した後にATR追跡ストップを有効にする
    • ブリン帯に触れた後,ATRの動態追跡停止を開始
    • ATR乘数の動的調整を使用してストップ距離を追跡

戦略的優位性

  1. リスクの管理には複数のレベルがあります
    • 固定ストップポイント保護本金
    • ダイナミック・トラッキング・ストップ・ロスト・ロック・プロフィット
    • ブリン帯の線路上の動的停止が追加保護を提供
  2. フレキシブルな移動平均の選択により,戦略は異なる市場状況に適応できます.
  3. ATR指数と組み合わせたダイナミック・トラッキング・ストップは,市場の波動性に応じて自動的に調整され,早退を防ぐことができます.
  4. 入場信号は,価格形状と技術指標を組み合わせて,信号の信頼性を高めます.
  5. ポジション管理と取引コストの設定をサポートし,実際の取引環境に近い

戦略リスク

  1. 市場が急激に揺れ動くと,取引が頻繁になり,取引コストが上がる可能性があります.
  2. 12%の固定ストップは,いくつかの非常に不安定な市場では過小かもしれません.
  3. ブリン帯信号は,トレンド市場において偽信号を生成する可能性があります.
  4. ATRの追跡停止は,激しい波動で大きな撤退を引き起こす可能性があります. 緩和策:
  • より長い時間周期で使用することが推奨される (30分−1時間)
  • 特定の品種の特性に合わせて調整できる
  • 偽信号を減らすためにトレンドフィルターを追加することを検討する
  • ATRの倍数を変化する市場状況に動的に調整する

戦略最適化の方向性

  1. 入場最適化:
  • 取引量確認メカニズムの追加
  • トレンド強度指数 フィルタリング信号を追加
  • 動力指標の補助判断を考慮する
  1. ストップ・ローズ・オプティマイゼーション
  • 固定ストップをATRベースのダイナミックストップに変更します.
  • 自動制御のアルゴリズム開発
  • ストップ距離は変動率に合わせて動的に調整されます.
  1. 移動平均の最適化:
  • 異なる周期组合をテストする
  • 適応サイクル研究
  • 移動平均の代わりに 価格行動を使うことを検討する
  1. ポジション管理の最適化:
  • 波動率に基づくポジション管理システム開発
  • バッチでポジションを構築および削減するメカニズムを実装する
  • 危険口のコントロール

要約する

この戦略は,ブリン帯とATR指標を介して,多層の取引システムを構築し,入場,止損,利益の結末などにおいてダイナミックな管理方法を採用している.戦略の優位性は,その完善したリスク制御システムと市場の波動に対する自己適応能力にある.提案された最適化方向によって,戦略には,大きな向上の余地がある.特に,より大きな時間周期で使用するのに適し,質の高い資産を持つ投資家にとって,ポジションの構築と減仓のタイミングを最適化するのに役立つ.

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

//@version=5
strategy("Demo GPT - Bollinger Bands Strategy with Tightened Trailing Stops", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_value=0.1, slippage=3)

// Input settings
length = input.int(20, minval=1)
maType = input.string("SMA", "Basis MA Type", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"])
src = input(close, title="Source")
mult = 1.5 // Standard deviation multiplier set to 1.5
offset = input.int(0, "Offset", minval=-500, maxval=500)
atrMultiplier = input.float(1.0, title="ATR Multiplier for Trailing Stop", minval=0.1) // ATR multiplier for trailing stop

// Time range filters
start_date = input(timestamp("2018-01-01 00:00"), title="Start Date")
end_date = input(timestamp("2069-12-31 23:59"), title="End Date")
in_date_range = true

// Moving average function
ma(source, length, _type) =>
    switch _type
        "SMA" => ta.sma(source, length)
        "EMA" => ta.ema(source, length)
        "SMMA (RMA)" => ta.rma(source, length)
        "WMA" => ta.wma(source, length)
        "VWMA" => ta.vwma(source, length)

// Calculate Bollinger Bands
basis = ma(src, length, maType)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev

// ATR Calculation
atr = ta.atr(length) // Use ATR for trailing stop adjustments

// Plotting
plot(basis, "Basis", color=#2962FF, offset=offset)
p1 = plot(upper, "Upper", color=#F23645, offset=offset)
p2 = plot(lower, "Lower", color=#089981, offset=offset)
fill(p1, p2, title="Background", color=color.rgb(33, 150, 243, 95))

// Candle color detection
isGreen = close > open
isRed = close < open

// Flags for entry and exit conditions
var bool redTouchedLower = false
var float targetPrice = na
var float stopLossPrice = na
var float trailingStopPrice = na

if in_date_range
    // Entry Logic: First green candle after a red candle touches the lower band
    if close < lower and isRed
        redTouchedLower := true
    if redTouchedLower and isGreen
        strategy.entry("Long", strategy.long)
        targetPrice := close * 1.2       // Set the target price to 20% above the entry price
        stopLossPrice := close * 0.88   // Set the stop loss to 12% below the entry price
        trailingStopPrice := na         // Reset trailing stop on entry
        redTouchedLower := false

    // Exit Logic: Trailing stop after 20% price increase
    if strategy.position_size > 0 and not na(targetPrice) and close >= targetPrice
        if na(trailingStopPrice)
            trailingStopPrice := close - atr * atrMultiplier // Initialize trailing stop using ATR
        trailingStopPrice := math.max(trailingStopPrice, close - atr * atrMultiplier) // Tighten dynamically based on ATR

    // Exit if the price falls below the trailing stop after 20% increase
    if strategy.position_size > 0 and not na(trailingStopPrice) and close < trailingStopPrice
        strategy.close("Long", comment="Trailing Stop After 20% Increase")
        targetPrice := na // Reset the target price
        stopLossPrice := na // Reset the stop loss price
        trailingStopPrice := na // Reset trailing stop

    // Stop Loss: Exit if the price drops 12% below the entry price
    if strategy.position_size > 0 and not na(stopLossPrice) and close <= stopLossPrice
        strategy.close("Long", comment="Stop Loss Triggered")
        targetPrice := na // Reset the target price
        stopLossPrice := na // Reset the stop loss price
        trailingStopPrice := na // Reset trailing stop

    // Trailing Stop: Activate after touching the upper band
    if strategy.position_size > 0 and close >= upper and isGreen
        if na(trailingStopPrice)
            trailingStopPrice := close - atr * atrMultiplier // Initialize trailing stop using ATR
        trailingStopPrice := math.max(trailingStopPrice, close - atr * atrMultiplier) // Tighten dynamically based on ATR

    // Exit if the price falls below the trailing stop
    if strategy.position_size > 0 and not na(trailingStopPrice) and close < trailingStopPrice
        strategy.close("Long", comment="Trailing Stop Triggered")
        trailingStopPrice := na // Reset trailing stop
        targetPrice := na // Reset the target price
        stopLossPrice := na // Reset the stop loss price