T3 移動平均トレンド追跡と移動ストップロス定量取引戦略

T3MA SMA EMA
作成日: 2024-11-28 15:17:13 最終変更日: 2024-11-28 15:17:13
コピー: 1 クリック数: 505
1
フォロー
1617
フォロワー

T3 移動平均トレンド追跡と移動ストップロス定量取引戦略

概要

この戦略は,T3平均線,トレンド追跡,移動ストップの仕組みを組み合わせた総合的な定量取引システムである.戦略は,T3移動平均線を介して市場のトレンド方向を識別し,レモントレンド指数とTDFI指数を使用してシグナルを確認し,移動ストップと固定ストップを組み合わせたリスク管理システムと連携し,トレンドの把握とリスクを効果的に制御する.

戦略原則

この戦略の核心には,トレンド識別,シグナル確認,リスク管理の3つの主要な部分が含まれています. まず,T3移動平均を主要なトレンド識別ツールとして使用し,T3平均は6倍指数移動平均を計算することで,落差を効果的に軽減し,平滑性を維持できます.次に,レモントレンド指数を使用して価格変動区間を計算し,TDFI指数と組み合わせてシグナルをフィルターし,価格が波動区間を突破し,TDFI指数が確認された場合にのみ取引シグナルが生成されます.最後に,戦略は,移動ストップと固定ストップを組み合わせた方法でリスク管理し,移動ストップは価格がアクティブピークに達した後に追跡し,固定ストップを保護メカニズムとして保持します.

戦略的優位性

  1. 複数の信号確認メカニズムにより取引の精度が向上
  2. T3平均線の使用により,偽突破の影響が軽減される.
  3. 柔軟なリスク管理システムで,利益を守る一方で,トレンドに十分な余地を与える
  4. 部分的なポジション停止をサポートし,利益の段階的な還元を実現します.
  5. パラメータは,異なる市場環境に応じて最適化するために,調整可能である

戦略リスク

  1. T3平均線計算は複雑で,計算の遅延がある可能性があります.
  2. 複数のシグナルの確認により,いくつかの取引機会を逃す可能性があります.
  3. 移動停止は,急激な波動で過早に発動する可能性があります.
  4. 価格の変動が大きくなり,効果的信号が作られる.
  5. 横盤市場では頻繁に偽信号が生じる可能性がある

戦略最適化の方向性

  1. 波動率指標の導入と移動停止パラメータの調整
  2. 市場環境認識モジュールを追加し,異なる市場条件で異なるパラメータを使用
  3. TDFI指標の計算周期を最適化し,信号のタイムリー性を向上させる
  4. 通信量要素を追加することを検討する
  5. 適応した部分停止比率設定機構の研究

要約する

これは,複数の技術指標の配合使用によって,取引信号の信頼性を保証するとともに,効果的なリスク管理を実現する,設計された包括的なトレンド追跡戦略である.戦略のモジュール化された設計は,中長期トレンド追跡システムの基礎の枠組みとして適した拡張性と最適化スペースを備えている.実際のアプリケーションでは,特定の取引品種と市場環境に応じてパラメータの最適化調整が推奨されている.

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

//@version=5
strategy("Lemon Trend Strategy", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
 
// Input parameters
lookbackPeriod = input.int(14, "Lookback Period")
t3Length = input.int(200, "T3 MA Length")
t3Factor = input.float(0.7, "T3 Factor", minval=0, maxval=1)

// 移动止损参数
trailingStopPct = input.float(1.5, "移动止损百分比", minval=0.1, step=0.1)
trailingStopActivationPct = input.float(1.0, "移动止损激活百分比", minval=0.1, step=0.1)
 
// === T3 Moving Average Function ===
t3(src, length, factor) =>
    // First EMA
    e1 = ta.ema(src, length)
    // Second EMA
    e2 = ta.ema(e1, length)
    // Third EMA
    e3 = ta.ema(e2, length)
    // Fourth EMA
    e4 = ta.ema(e3, length)
    // Fifth EMA
    e5 = ta.ema(e4, length)
    // Sixth EMA
    e6 = ta.ema(e5, length)
   
    c1 = -factor * factor * factor
    c2 = 3 * factor * factor + 3 * factor * factor * factor
    c3 = -6 * factor * factor - 3 * factor - 3 * factor * factor * factor
    c4 = 1 + 3 * factor + factor * factor * factor + 3 * factor * factor
   
    t3 = c1 * e6 + c2 * e5 + c3 * e4 + c4 * e3
 
// Calculate T3 MA
t3ma = t3(close, t3Length, t3Factor)
plot(t3ma, "T3 MA", color=color.blue)
 
// === Lemon Trend Indicator ===
highLowDiff = high - low
normalizedDiff = ta.sma(highLowDiff, lookbackPeriod)
upperBand = ta.highest(high, lookbackPeriod)
lowerBand = ta.lowest(low, lookbackPeriod)
buySignal = ta.crossover(close, upperBand - normalizedDiff)
sellSignal = ta.crossunder(close, lowerBand + normalizedDiff)
 
// === TDFI Indicator ===
tdfiLength = input.int(14, "TDFI Length")
tdfi = ta.ema(close - close[1], tdfiLength)
tdfiSignal = ta.ema(tdfi, 9)
 
// Plot signals
plotshape(buySignal and tdfi > tdfiSignal and close > t3ma, "Buy Signal", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(sellSignal and tdfi < tdfiSignal and close < t3ma, "Sell Signal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)
 
// === Strategy Logic ===
longCondition = buySignal and tdfi > tdfiSignal and close > t3ma
shortCondition = sellSignal and tdfi < tdfiSignal and close < t3ma
 
// 计算移动止损价格
var float longTrailingStop = na
var float shortTrailingStop = na

// 更新移动止损价格
if (strategy.position_size > 0)
    threshold = strategy.position_avg_price * (1 + trailingStopActivationPct / 100)
    if (high > threshold)
        stopPrice = high * (1 - trailingStopPct / 100)
        if (na(longTrailingStop) or stopPrice > longTrailingStop)
            longTrailingStop := stopPrice
    
if (strategy.position_size < 0)
    threshold = strategy.position_avg_price * (1 - trailingStopActivationPct / 100)
    if (low < threshold)
        stopPrice = low * (1 + trailingStopPct / 100)
        if (na(shortTrailingStop) or stopPrice < shortTrailingStop)
            shortTrailingStop := stopPrice

// Entry orders
if (longCondition)
    strategy.entry("Long", strategy.long)
    longTrailingStop := na
    
if (shortCondition)
    strategy.entry("Short", strategy.short)
    shortTrailingStop := na
 
// Calculate stop loss and take profit levels
longStopLoss = ta.lowest(low, lookbackPeriod)
shortStopLoss = ta.highest(high, lookbackPeriod)
 
// Exit conditions with fixed R:R
fixedRR = input.float(1.8, "Fixed Risk:Reward Ratio")
partialExitPct = input.float(50.0, "Partial Exit Percentage", minval=0, maxval=100) / 100
 
// 综合移动止损和固定止损
if (strategy.position_size > 0)
    longTakeProfit = strategy.position_avg_price + (strategy.position_avg_price - longStopLoss) * fixedRR
    stopPrice = na(longTrailingStop) ? longStopLoss : math.max(longStopLoss, longTrailingStop)
    strategy.exit("Long Exit", "Long", qty_percent=partialExitPct, stop=stopPrice, limit=longTakeProfit)
    
if (strategy.position_size < 0)
    shortTakeProfit = strategy.position_avg_price - (shortStopLoss - strategy.position_avg_price) * fixedRR
    stopPrice = na(shortTrailingStop) ? shortStopLoss : math.min(shortStopLoss, shortTrailingStop)
    strategy.exit("Short Exit", "Short", qty_percent=partialExitPct, stop=stopPrice, limit=shortTakeProfit)

// 绘制移动止损线
plot(strategy.position_size > 0 ? longTrailingStop : na, "Long Trailing Stop", color=color.red, style=plot.style_linebr)
plot(strategy.position_size < 0 ? shortTrailingStop : na, "Short Trailing Stop", color=color.red, style=plot.style_linebr)