MACD と R:R 比率の日中制限収束戦略

MACD
作成日: 2024-06-03 16:47:56 最終変更日: 2024-06-03 16:47:56
コピー: 3 クリック数: 611
1
フォロー
1617
フォロワー

MACD と R:R 比率の日中制限収束戦略

概要

この戦略は,MACD指標の収束と散布に基づいて取引信号を判断する.MACD線と信号線が交差し,MACD線の値が1.5より大きいまたは1.5より小さいときは,それぞれ多行および空行信号を生成する.同時に,戦略は,固定したストップ・ロスの位置を設定し,リスク・リターン比 (R:R) の概念を導入する.さらに,この戦略は,日中の最大損失と最大利益の制限,より厳しい移動ストップ措置を採用し,リスクをよりよく制御する.

戦略原則

  1. MACD指標のMACD線と信号線を計算する.
  2. MACD線と信号線の交差を判断し,また,MACD線の値が一定の値を超えているかどうかを考慮する.
  3. 複数のシグナルが表示された場合,ポジションを開き,現在の最高価格+600最小変動単位でストップ価格を設定し,現在の最低価格-100最小変動単位でストップ価格を設定します.
  4. 空調の信号が出たとき,空調を設定し,ストップ価格を現在の最低価格-600最小変動単位,ストップ価格を現在の最高価格+100最小変動単位に設定します.
  5. 移動ストップロジックを導入し,価格が相対開設価格の上昇 ((多頭) または下降 ((空頭) が300最小変動単位を超えると,ストップ価格を開設価格+ ((閉店価格-開設価格-300) ((多頭) または開設価格- ((開設価格-閉店価格-300) ((空頭) に移動する.
  6. 1日の最大損失と最大利益の制限を設定し,その日の損失が600最小変動単位または利益が1800最小変動単位に達すると,すべてのポジションをクリアします.

優位分析

  1. MACD指数と値下げ条件を組み合わせて,部分的なノイズ信号を効果的にフィルターします.
  2. 固定リスク・リターン比率 ((R:R),取引毎のリスク・リターンは制御できる。
  3. 移動ストップロジックは,トレンドが形成された後に利益を保護し,撤回を減らすことができます.
  4. 1日の最大損失と利益の制限は,1日間のリスクの開口を制御し,過度の損失や利益の撤回を避けるのに役立ちます.

リスク分析

  1. MACD指数は遅滞があり,信号遅延または誤信号が発生する可能性があります.
  2. 固定ストップ・ストップ・ポイントは,異なる市場状況に適応できない可能性があり,揺れ動いている状況で頻繁にストップを誘発する可能性がある.
  3. モバイルストップロジックは,トレンドが逆転したときに,タイムストップができない可能性があり,利益の反転を引き起こします.
  4. 一日の最大損失と利益の制限は,戦略が1日間の市場動向が明確になったときに,早めに平仓し,潜在的な利益を逃す可能性があります.

最適化の方向

  1. 複数の時間枠のMACD指標を用いて信号を確認し,信号の正確性を向上させる.
  2. 市場変動の動態に応じて,異なる市場状況に適応するためにストップ・ストップ・ストラップの位を調整する.
  3. ATR指数に基づいて移動ストップ距離を設定するなど,移動ストップロジックを最適化して,価格変動に適した状態にします.
  4. 1日の最大損失と利益の制限をパラメータ最適化して,適切な制限値を見つけ,リスクを制御しながら,トレンド状況をできるだけ捉える.

要約する

この戦略は,MACD指標の収束と散布によって取引信号を判断し,リスク報酬率,移動ストップと日内制限などのリスク管理策を導入した.戦略は,トレンドの動きを一定程度に捉え,リスクを制御することができたが,いくつかの最適化と改善の余地がある.将来,信号確認,ストップストップ,移動ストップと日内制限などの次元から最適化することを考慮して,より安定した,可視な報酬を得ることを期待することができる.

ストラテジーソースコード
/*backtest
start: 2023-05-28 00:00:00
end: 2024-06-02 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © DD173838

//@version=5
strategy("MACD Convergence Strategy with R:R, Daily Limits, and Tighter Stop Loss", overlay=true, default_qty_type=strategy.fixed, default_qty_value=1)

// MACD settings
fastLength = input.int(12, title="Fast Length", minval=1)
slowLength = input.int(26, title="Slow Length", minval=1)
signalSmoothing = input.int(9, title="Signal Smoothing", minval=1)
source = input(close, title="Source")

// Calculate MACD
[macdLine, signalLine, _] = ta.macd(source, fastLength, slowLength, signalSmoothing)

// Plot MACD and signal line
plot(macdLine, title="MACD Line", color=color.blue)
plot(signalLine, title="Signal Line", color=color.red)

// Define convergence conditions
macdConvergenceUp = ta.crossover(macdLine, signalLine) and macdLine > 1.5
macdConvergenceDown = ta.crossunder(macdLine, signalLine) and macdLine < -1.5

// Define take profit and stop loss

        
    
takeProfit = 600
stopLoss = 100

// Plot buy and sell signals on the chart
plotshape(series=macdConvergenceDown, title="Short Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SHORT")
plotshape(series=macdConvergenceUp, title="Long Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="LONG")

// Execute short and long orders with defined take profit and stop loss
if (macdConvergenceDown)
    strategy.entry("Short", strategy.short, qty=1, stop=high + (stopLoss / syminfo.mintick), limit=low - (takeProfit / syminfo.mintick))

if (macdConvergenceUp)
    strategy.entry("Long", strategy.long, qty=1, stop=low - (stopLoss / syminfo.mintick), limit=high + (takeProfit / syminfo.mintick))

// Trailing stop logic
var float entryPrice = na
var float trailingStopPrice = na

if (strategy.position_size != 0)
    entryPrice := strategy.opentrades.entry_price(0)

if (strategy.position_size > 0)  // For long positions
    if (close - entryPrice > 300)
        trailingStopPrice := entryPrice + (close - entryPrice - 300)

if (strategy.position_size < 0)  // For short positions
    if (entryPrice - close > 300)
        trailingStopPrice := entryPrice - (entryPrice - close - 300)

if (strategy.position_size > 0 and not na(trailingStopPrice) and close < trailingStopPrice)
    strategy.close("Long", comment="Trailing Stop")

if (strategy.position_size < 0 and not na(trailingStopPrice) and close > trailingStopPrice)
    strategy.close("Short", comment="Trailing Stop")

// Daily drawdown and profit limits
var float startOfDayEquity = na
if (na(startOfDayEquity) or ta.change(time('D')) != 0)
    startOfDayEquity := strategy.equity

maxDailyLoss = 600
maxDailyProfit = 1800
currentDailyPL = strategy.equity - startOfDayEquity

if (currentDailyPL <= -maxDailyLoss)
    strategy.close_all(comment="Max Daily Loss Reached")

if (currentDailyPL >= maxDailyProfit)
    strategy.close_all(comment="Max Daily Profit Reached")