複数時間枠トレンド追跡取引システム (MTF-ATR-MACD)

EMA RSI ATR MACD MTF SL TP
作成日: 2024-11-25 14:42:33 最終変更日: 2024-11-25 14:42:33
コピー: 4 クリック数: 540
1
フォロー
1617
フォロワー

複数時間枠トレンド追跡取引システム (MTF-ATR-MACD)

概要

この戦略は,複数のタイムフレームの分析,平均線システム,動向指数および波動率指数を組み合わせた総合的なトレンド追跡取引システムである.システムは,短期と長期の指数移動平均の交差によってトレンドの方向性を認識し,相対的に強い指標のRSIを使用して,超買い超売り判断を行い,MACDと組み合わせて動向確認を行い,より高いタイムフレームのEMAをトレンドフィルターシステムとして利用する.ATRベースのダイナミックストップ・ロズ・アンド・ゲインス・プログラムを採用し,市場の波動性に応じて自律的に調整することができる.

戦略原則

戦略は,取引の決定に多層の検証メカニズムを使用します.

  1. トレンド識別層: 9期と21期のEMAの交差を用い,トレンドの変化を捉える
  2. 動力の確認層: MACD指標 ((12,26,9) の交差と方向によるトレンド動力の検証
  3. 過買過売フィルター:RSI ((14) インジケータを使用して70/30のレベルでフィルター
  4. 高時間枠確認:日線レベルEMAをトレンドフィルターとして選択的に使用
  5. リスクマネジメント:1.5倍ATRをストップ・ロスの追跡として使用し,2倍ATRをリターンの設定

システムは,複数の条件を満たした後にポジションを開きます:EMA交差,RSIが極限に達していない,MACDの方向が正しく,高いタイムフレームのトレンドが確認されている.出場は,追跡ストップと固定利益目標の組み合わせを使用する.

戦略的優位性

  1. マルチ認証メカニズムにより,偽信号の減少が顕著です.
  2. 高タイムフレームのトレンドフィルターで勝利率を上げます
  3. 変動率に基づく動的止損の適応性
  4. 完全なリスク管理システム
  5. パラメータは,異なる市場の特徴に応じて柔軟に調整できます.
  6. 市場環境に適応する双方向取引をサポートする
  7. 動向とトレンドの両方に注目する指標の組み合わせ

戦略リスク

  1. 複数の条件により,一部の取引機会を逃す可能性があります.
  2. 不安定な市場では頻繁に取引される可能性がある
  3. パラメータの最適化は過剰適合につながる可能性がある
  4. 高時間枠の確認は入学遅延を引き起こす可能性がある 解決:
  • 市場特有の動態調整パラメータ
  • 取引方向の選択の柔軟性を高めること
  • 波動率のフィルタリング
  • 最適化パラメータの自己適応機構

戦略最適化の方向性

  1. 波動率のフィルタリングを導入し,高波動期間のポジション調整
  2. 開発パラメータの適応メカニズム,市場の状況に応じて動的に調整
  3. 取引量指標の確認信号の有効性を高める
  4. 高タイムフレームのトレンド判断の論理を最適化
  5. 減損策を完善し,減損期間を延長することを検討
  6. 戦略性能評価モジュール開発

要約する

この戦略は,複数の技術指標の組み合わせと厳格なリスク管理制度によって,トレンド市場で安定した収益を得ることができる完全なトレンド追跡取引システムである.システムの拡張性は強く,最適化によって異なる市場環境に適応することができます.

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

//@version=5 
strategy("Trend Following with ATR, MTF Confirmation, and MACD", overlay=true)

// Parameters
emaShortPeriod = input.int(9, title="Short EMA Period", minval=1)
emaLongPeriod = input.int(21, title="Long EMA Period", minval=1)
rsiPeriod = input.int(14, title="RSI Period", minval=1)
rsiOverbought = input.int(70, title="RSI Overbought", minval=50)
rsiOversold = input.int(30, title="RSI Oversold", minval=1)
atrPeriod = input.int(14, title="ATR Period", minval=1)
atrMultiplier = input.float(1.5, title="ATR Multiplier", minval=0.1)
takeProfitATRMultiplier = input.float(2.0, title="Take Profit ATR Multiplier", minval=0.1)

// Multi-timeframe settings
htfEMAEnabled = input.bool(true, title="Use Higher Timeframe EMA Confirmation?", inline="htf")
htfEMATimeframe = input.timeframe("D", title="Higher Timeframe", inline="htf")

// MACD Parameters
macdShortPeriod = input.int(12, title="MACD Short Period", minval=1)
macdLongPeriod = input.int(26, title="MACD Long Period", minval=1)
macdSignalPeriod = input.int(9, title="MACD Signal Period", minval=1)

// Select trade direction
tradeDirection = input.string("Both", title="Trade Direction", options=["Both", "Long", "Short"])

// Calculating indicators
emaShort = ta.ema(close, emaShortPeriod)
emaLong = ta.ema(close, emaLongPeriod)
rsiValue = ta.rsi(close, rsiPeriod)
atrValue = ta.atr(atrPeriod)

// Calculate MACD
[macdLine, macdSignalLine, _] = ta.macd(close, macdShortPeriod, macdLongPeriod, macdSignalPeriod)

// Higher timeframe EMA confirmation
htfEMALong = request.security(syminfo.tickerid, htfEMATimeframe, ta.ema(close, emaLongPeriod))

// Trading conditions
longCondition = ta.crossover(emaShort, emaLong) and rsiValue < rsiOverbought and (not htfEMAEnabled or close > htfEMALong) and macdLine > macdSignalLine
shortCondition = ta.crossunder(emaShort, emaLong) and rsiValue > rsiOversold and (not htfEMAEnabled or close < htfEMALong) and macdLine < macdSignalLine

// Plotting EMAs
plot(emaShort, title="EMA Short", color=color.green)
plot(emaLong, title="EMA Long", color=color.red)

// Plotting MACD
hline(0, "Zero Line", color=color.gray)
plot(macdLine - macdSignalLine, title="MACD Histogram", color=color.green, style=plot.style_histogram)
plot(macdLine, title="MACD Line", color=color.blue)
plot(macdSignalLine, title="MACD Signal Line", color=color.red)

// Trailing Stop-Loss and Take-Profit levels
var float trailStopLoss = na
var float trailTakeProfit = na

if (strategy.position_size > 0) // Long Position
    trailStopLoss := na(trailStopLoss) ? close - atrValue * atrMultiplier : math.max(trailStopLoss, close - atrValue * atrMultiplier)
    trailTakeProfit := close + atrValue * takeProfitATRMultiplier
    strategy.exit("Exit Long", "Long", stop=trailStopLoss, limit=trailTakeProfit, when=shortCondition)

if (strategy.position_size < 0) // Short Position
    trailStopLoss := na(trailStopLoss) ? close + atrValue * atrMultiplier : math.min(trailStopLoss, close + atrValue * atrMultiplier)
    trailTakeProfit := close - atrValue * takeProfitATRMultiplier
    strategy.exit("Exit Short", "Short", stop=trailStopLoss, limit=trailTakeProfit, when=longCondition)

// Strategy Entry
if (longCondition and (tradeDirection == "Both" or tradeDirection == "Long"))
    strategy.entry("Long", strategy.long)
    
if (shortCondition and (tradeDirection == "Both" or tradeDirection == "Short"))
    strategy.entry("Short", strategy.short)

// Plotting Buy/Sell signals
plotshape(series=longCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=shortCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")

// Plotting Trailing Stop-Loss and Take-Profit levels
plot(strategy.position_size > 0 ? trailStopLoss : na, title="Long Trailing Stop Loss", color=color.red, linewidth=2, style=plot.style_line)
plot(strategy.position_size < 0 ? trailStopLoss : na, title="Short Trailing Stop Loss", color=color.green, linewidth=2, style=plot.style_line)
plot(strategy.position_size > 0 ? trailTakeProfit : na, title="Long Take Profit", color=color.blue, linewidth=2, style=plot.style_line)
plot(strategy.position_size < 0 ? trailTakeProfit : na, title="Short Take Profit", color=color.orange, linewidth=2, style=plot.style_line)