ZスコアモメンタムATRストップロス戦略とリスクリターン比を組み合わせて取引システムを最適化します

ATR RR MA
作成日: 2025-02-20 13:40:12 最終変更日: 2025-02-27 17:41:05
コピー: 1 クリック数: 398
2
フォロー
319
フォロワー

ZスコアモメンタムATRストップロス戦略とリスクリターン比を組み合わせて取引システムを最適化します ZスコアモメンタムATRストップロス戦略とリスクリターン比を組み合わせて取引システムを最適化します

概要

この戦略は,複数の技術指標を組み合わせた完全な取引システムであり,主にZスコアに基づいて取引量とK線エンティティの大きさの異常値を測定し,ATR (平均リアル波幅) を使用してダイナミックなストップローズを設定します.このシステムは,リスク/利益の比率 (RR) を統合し,利益の目標を最適化し,多次元技術分析によって信頼できる取引信号を提供します.

戦略原則

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

  1. Zスコア分析:取引量とK線エンティティの標準差を計算し,市場の異常活性を識別する
  2. トレンド確認: 隣接するK線の高低点とクローズアップ価格を分析してトレンドの方向を確認する
  3. ATR ストップ: 動的なATR値でストップ位置を設定し,より柔軟なリスク管理を提供します.
  4. RR:設定されたRR比率に基づいて収益目標の自動計算
  5. ビジュアルマーク:取引シグナルと重要な価格レベルをグラフにマークする

戦略的優位性

  1. 多次元信号確認:取引量,価格動力,トレンド方向を組み合わせて取引信号の信頼性を高める
  2. ダイナミックなリスク管理:ATRによる自律的な止損,市場の波動に適応する
  3. 柔軟なパラメータ配置:Zスコアの減值,ATR倍数,リスク・リターン比率の調整を許可する
  4. 正確な入場時刻:Zスコア異常値を使用して,重要な取引機会を識別する
  5. 明確な可視化:入場点,ストップ・ロズ・ポイント,利益目標がグラフに明確に表示される

戦略リスク

  1. パラメータの感受性:Zスコアの値とATR倍数の設定は,取引頻度とリスク管理に直接影響する
  2. 市場環境依存性:低波動環境では取引信号が少ない可能性
  3. 計算の複雑さ:複数の指標の計算により,信号生成の遅延が発生する
  4. スライドポイントリスク: 急速な市場では,実際の実行価格とシグナル価格の偏差に直面する可能性があります.
  5. 偽のブレイクリスク: 市場を整理する際に誤ったブレイクシグナルを誘発する可能性がある

戦略最適化の方向性

  1. 市場環境フィルター:市場の変動率フィルターを追加し,異なる市場環境で動的にパラメータを調整する
  2. シグナル確認機構:RSIやMACDのような技術指標を交叉検証するために導入
  3. ポジション管理の最適化:波動率と口座リスクに基づく動的ポジション調整
  4. 多時間周期分析:より高い時間周期を統合する傾向を確認し,取引成功率を向上させる
  5. 信号フィルタリング最適化:偽信号を減らすために追加のフィルタリング条件を追加

要約する

この戦略は,Zスコア分析,ATRの止損とリスク/利益の比率の最適化と組み合わせて,完全な取引システムを構築している.システムの優位性は,多次元的な信号確認と柔軟なリスク管理にあるが,パラメータ設定と市場環境の影響を考慮する必要がある.戦略は,推奨された最適化方向によって,その安定性と適応性をさらに向上させることができる.

ストラテジーソースコード
/*backtest
start: 2024-10-01 00:00:00
end: 2025-02-18 08:00:00
period: 2h
basePeriod: 2h
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/

//@version=5
strategy("admbrk | Candle Color & Price Alarm with ATR Stop", overlay=true, initial_capital=50, default_qty_type=strategy.cash, default_qty_value=200, commission_type=strategy.commission.percent, commission_value=0.05, pyramiding=3)

// **Risk/Reward ratio (RR) as input**
rr = input.float(2.0, title="Risk/Reward Ratio (RR)", step=0.1)

// **Z-score calculation function**
f_zscore(src, len) =>
    mean = ta.sma(src, len)     
    std = ta.stdev(src, len)
    (src - mean) / std

// **Z-score calculations**
len = input(20, "Z-Score MA Length")
z1 = input.float(1.5, "Threshold z1", step=0.1)
z2 = input.float(2.5, "Threshold z2", step=0.1)

z_volume = f_zscore(volume, len)
z_body = f_zscore(math.abs(close - open), len)

i_src = input.string("Volume", title="Source", options=["Volume", "Body size", "Any", "All"])

float z = na
if i_src == "Volume"
    z := z_volume
else if i_src == "Body size"
    z := z_body
else if i_src == "Any"
    z := math.max(z_volume, z_body)
else if i_src == "All"
    z := math.min(z_volume, z_body)

// **Determine trend direction**
green = close >= open
red = close < open

// **Long and Short signals**
longSignal = barstate.isconfirmed and red[1] and low < low[1] and green
shortSignal = barstate.isconfirmed and green[1] and high > high[1] and red

long = longSignal and (z >= z1)
short = shortSignal and (z >= z1)

// **ATR calculation (for ATR Stop)**
atrLength = input.int(14, title="ATR Length")
atrMultiplier = input.float(1.5, title="ATR Stop Multiplier")
atrValue = ta.atr(atrLength)

// **ATR-based stop-loss calculation**
long_atr_stop = close - atrValue * atrMultiplier
short_atr_stop = close + atrValue * atrMultiplier

// **Stop-loss setting (set to the lowest/highest wick of the last two bars)**
long_sl = ta.lowest(low, 2)  // Long stop-loss (lowest of the last 2 bars)
short_sl = ta.highest(high, 2) // Short stop-loss (highest of the last 2 bars)

// **Take-profit calculation (with RR)**
long_tp = close + (close - long_sl) * rr
short_tp = close - (short_sl - close) * rr

triggerAlarm(symbol)=>
    status = close
    var string message = na
    alarmMessageJSON = syminfo.ticker + message +"\\n" + "Price: " + str.tostring(status) 
    
if long
    // Open Long position
    strategy.entry("Long", strategy.long)
    strategy.exit("Long Exit", from_entry="Long", stop=math.max(long_sl, long_atr_stop), limit=long_tp)
    

if short
    // Open Short position
    strategy.entry("Short", strategy.short)
    strategy.exit("Short Exit", from_entry="Short", stop=math.min(short_sl, short_atr_stop), limit=short_tp)
    

// **Coloring the candles (BUY = Green, SELL = Red)**
barcolor(long ? color.green : short ? color.red : na)

// **Add entry/exit markers on the chart**
plotshape(long, title="BUY Signal", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small, text="BUY")
plotshape(short, title="SELL Signal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small, text="SELL")

// **Plot TP and SL markers on exits**
exitLong = strategy.position_size < strategy.position_size[1] and strategy.position_size[1] > 0
exitShort = strategy.position_size > strategy.position_size[1] and strategy.position_size[1] < 0

plotshape(exitLong, title="Long Exit", location=location.abovebar, color=color.blue, style=shape.labeldown, size=size.tiny, text="TP/SL")
plotshape(exitShort, title="Short Exit", location=location.belowbar, color=color.orange, style=shape.labelup, size=size.tiny, text="TP/SL")

// **Add alerts**
alertcondition(long, title="Long Signal", message="Long signal triggered!")
alertcondition(short, title="Short Signal", message="Short signal triggered!")