マルチレベルジグザグパーセンテージリトレースメントとストキャスティクス指標取引戦略の組み合わせ

ZZ ATR RSI STOCH SMA
作成日: 2025-02-21 11:18:39 最終変更日: 2025-02-21 11:18:39
コピー: 0 クリック数: 477
2
フォロー
319
フォロワー

マルチレベルジグザグパーセンテージリトレースメントとストキャスティクス指標取引戦略の組み合わせ マルチレベルジグザグパーセンテージリトレースメントとストキャスティクス指標取引戦略の組み合わせ

概要

この戦略は,ZigZag百分引き下げとランダムな指標 ((Stochastic) を組み合わせた取引システムである.戦略は,ダイナミックに調整されたZigZag指標によって,市場動向の重要な転換点を識別し,ランダムな指標のオーバーバイオーバーセールシグナルと組み合わせて,場に入るタイミングを最適化する.システムには,リスク管理を実現するために,ストップ・ロスとストップ・ストップの仕組みも統合されている.

戦略原則

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

  1. 動的ZigZag指標 - 手動設定または異なる周期 ((5-250) に基づくATR動的調整撤回パーセントをサポートする
  2. ランダム指数フィルタリング - 9周期K値と3周期滑らかなランダム指数
  3. トランジションシグナル生成:
    • 購入条件:価格が反転線を突破し,ランダムな指標K値が20未満
    • 販売条件:価格が反転線を下回り,ランダムなK値が80以上
  4. リスクマネジメント - 固定ポイントのストップ・ローズ (100ポイント) とストップ・ストップ (300ポイント)

戦略的優位性

  1. 適応性 - ATRによる動的調整により,異なる市場環境に戦略を適応させる
  2. 多重確認 - トレンドと動力の指標を組み合わせて,偽信号を低減する
  3. リスクは制御可能 - 完ぺきな止損防止システム
  4. 信号の明晰さ - 取引信号が明晰で実行しやすい
  5. パラメータの柔軟性 - 複数のパラメータのカスタマイズをサポートし,最適化が容易である

戦略リスク

  1. 震動市場リスク - 区間震動の状況で頻繁にストップをトリガーする可能性がある
  2. スリップポイントリスク - 高速で大きなスリップポイントが発生する可能性がある
  3. 固定ストップリスク - 固定ポイントストップはすべての市場環境には適さない
  4. 偽突破リスク - 整合区間で偽突破信号が生じる可能性がある
  5. パラメータの感受性 - パラメータの選択は,戦略のパフォーマンスに大きな影響を与える

戦略最適化の方向性

  1. 動的ストップ・オプティマイゼーション - ATRまたは波動率を使用して動的にストップ・ポジションを調整することを検討する
  2. 市場環境のフィルター - トレンドの強さの指標を追加し,強いトレンドの時にポジションを開きます
  3. 信号確認強化 - 交付量確認を追加することを検討
  4. 入場時間を最適化 - 価格形態認識を導入し,入場精度を向上させる
  5. ポジション管理の改善 - 変動率に基づくポジション規模の動的調整

要約する

この戦略は,ZigZagとランダムな指標を組み合わせて,より完全な取引システムを構築する.戦略の主要な特徴は,シグナルが明確で,リスクは制御可能であるが,実際の市場状況に応じてパラメータの最適化が必要である.実体取引の前に十分な反射を行うことを推奨し,市場経験と組み合わせて戦略の継続的な改善を行う.

ストラテジーソースコード
/*backtest
start: 2025-02-18 14:00:00
end: 2025-02-20 00:00:00
period: 5m
basePeriod: 5m
exchanges: [{"eid":"Binance","currency":"SOL_USDT"}]
*/

//@version=5
strategy("[RS]ZigZag Percent Reversal with Stochastic Strategy", overlay=true)

//  ||---}---------------------------------------------------------------------||

//  |--------------------------------------------------------------------------||
//  |   ZigZag:                                                                ||
//  |--------------------------------------------------------------------------||
//  |{
string percent_method = input.string(
         defval="MANUAL", 
         title="Method to use for the zigzag reversal range:", 
         options=[
             "MANUAL", 
             "ATR005 * X", "ATR010 * X", "ATR020 * X", "ATR050 * X", "ATR100 * X", "ATR250 * X"
             ]
         )

var float percent = input.float(
         defval=0.25, 
         title="Percent of last pivot price for zigzag reversal:", 
         minval=0.0, maxval=99.0
         ) / 100

float percent_multiplier = input.float(
         defval=1.0, 
         title="Multiplier to apply to ATR if applicable:"
         )
if percent_method == "ATR005 * X"
    percent := ta.atr(5) / open * percent_multiplier
if percent_method == "ATR010 * X"
    percent := ta.atr(10) / open * percent_multiplier
if percent_method == "ATR020 * X"
    percent := ta.atr(20) / open * percent_multiplier
if percent_method == "ATR050 * X"
    percent := ta.atr(50) / open * percent_multiplier
if percent_method == "ATR100 * X"
    percent := ta.atr(100) / open * percent_multiplier
if percent_method == "ATR250 * X"
    percent := ta.atr(250) / open * percent_multiplier

//  ||-------------------------------------------------------------------------||
//  ||  zigzag function:
//  ||-------------------------------------------------------------------------||
//  |{
f_zz(_percent)=>


    //  direction after last pivot
    var bool _is_direction_up = na
    //  track highest price since last lower pivot
    var float _htrack = na
    //  track lowest price since last higher pivot
    var float _ltrack = na
    //  zigzag variable for plotting
    var float _pivot = na
    //  range needed for reaching reversal threshold
    float _reverse_range = 0.0
    //  real pivot time
    var int _real_pivot_time = na
    var int _htime = na
    var int _ltime = na
    //  reverse line
    var float _reverse_line = na
    
    if bar_index >= 1
        
        if na(_is_direction_up)
            _is_direction_up := true
        
        _reverse_range := nz(_pivot[1]) * _percent
        
        if _is_direction_up
            _ltrack := na
            _ltime := time
            
            if na(_htrack)
                if high > high[1]
                    _htrack := high
                    _htime := time
                else
                    _htrack := high[1]
                    _htime := time[1]
            else
                if high > _htrack
                    _htrack := high
                    _htime := time

            // Reversal line calculation based on the current candle's closing price
            _reverse_line := _htrack - _reverse_range
            
            // If close <= reversal line, mark pivot and reverse direction
            if close <= _reverse_line
                _pivot := _htrack
                _real_pivot_time := _htime
                _is_direction_up := false

        if not _is_direction_up
            _htrack := na
            _htime := na
            
            if na(_ltrack)
                if low < low[1]
                    _ltrack := low
                    _ltime := time
                else
                    _ltrack := low[1]
                    _ltime := time[1]
            else
                if low < _ltrack
                    _ltrack := low
                    _ltime := time
                
            // Reversal line calculation based on the current candle's closing price
            _reverse_line := _ltrack + _reverse_range
            
            // If close >= reversal line, mark pivot and reverse direction
            if close >= _reverse_line
                _pivot := _ltrack
                _real_pivot_time := _ltime
                _is_direction_up := true

    [_pivot, _is_direction_up, _reverse_line, _real_pivot_time]

[pivot, direction_up, reverse_line, pivot_time] = f_zz(percent)

// Çizim
// Sabit Reversal Line (fiyat seviyesinde sabit)
var float static_reverse_line = na
if (not na(reverse_line))
    static_reverse_line := reverse_line

plot(series=static_reverse_line, color=color.gray, style=plot.style_line, title="Reversal Line", trackprice=false)

//  ||-------------------------------------------------------------------------||
//  ||  Stochastic:                                                            ||
//  ||-------------------------------------------------------------------------||
//  |{
K_length = 9
K_smoothing = 3

// Stochastic %K hesaplama
stochK = ta.sma(ta.stoch(close, high, low, K_length), K_smoothing)

//  ||-------------------------------------------------------------------------||
//  ||  Custom Buy/Sell Signals:
//  ||-------------------------------------------------------------------------||
//  |{
// Buy sinyali: Fiyat reversal line'ının üstünde ve stochastic K değeri 20'nin altında ise
buy_signal = close > static_reverse_line and stochK < 20

// Sell sinyali: Fiyat reversal line'ının altındaysa ve stochastic K değeri 80'in üstünde ise
sell_signal = close < static_reverse_line and stochK > 80

// Alım ve satım sinyali için strateji girişlerini ekle
long_condition = buy_signal
short_condition = sell_signal

// **Burada Stop Loss ve Take Profit değerleri ayarlandı**
stop_loss_pips = 100  // Stop Loss 10 pip
take_profit_pips = 300  // Take Profit 30 pip

// Stop Loss ve Take Profit seviyeleri hesaplanıyor
long_stop_loss = close - stop_loss_pips * syminfo.mintick
long_take_profit = close + take_profit_pips * syminfo.mintick
short_stop_loss = close + stop_loss_pips * syminfo.mintick
short_take_profit = close - take_profit_pips * syminfo.mintick

// Long stratejisi: Alım sinyali ve stop loss/take profit seviyeleri ile
if long_condition
    strategy.entry("Buy", strategy.long, stop=long_stop_loss, limit=long_take_profit)
    strategy.exit("Take Profit / Stop Loss", from_entry="Buy", stop=long_stop_loss, limit=long_take_profit)
    // Webhook ile alım bildirimi gönder
    alert("Buy Signal Triggered!", alert.freq_once_per_bar)

// Short stratejisi: Satım sinyali ve stop loss/take profit seviyeleri ile
if short_condition
    strategy.entry("Sell", strategy.short, stop=short_stop_loss, limit=short_take_profit)
    strategy.exit("Take Profit / Stop Loss", from_entry="Sell", stop=short_stop_loss, limit=short_take_profit)
    // Webhook ile satım bildirimi gönder
    alert("Sell Signal Triggered!", alert.freq_once_per_bar)

// Alım sinyali gösterimi
plotshape(series=buy_signal, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal", text="BUY", textcolor=color.white)
// Satım sinyali gösterimi
plotshape(series=sell_signal, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal", text="SELL", textcolor=color.white)