現在のトレンドトレンドフォロー戦略


作成日: 2023-09-21 15:00:08 最終変更日: 2023-09-21 15:00:08
コピー: 0 クリック数: 615
1
フォロー
1617
フォロワー

概要

PresentTrend戦略は,独自のカスタムトレンドフォロー戦略である.この戦略は,短期および長期の市場トレンドを組み合わせて,異なる市場条件に適用されます.

戦略原則

この戦略は2つの部分から構成されています.

  1. カスタムRSIまたはMFI指標:この指標は,RSIまたはMFIによって計算されたPresentTrend値に基づいて,その値に基づいて金叉死叉が購入と販売のシグナルを生成し,潜在的トレンドの逆転を示します.

  2. ATR指数:これは,平均的な実際の波動範囲 ((ATR) を使って,流行のトレンドフォロー指数である.

両方の戦略の買取と売却のシグナルが同時にトリガーされると,その戦略はポジションをオーバーまたはオフにします.これは,短期と長期の傾向が一致しているときにのみ取引が起こるようにし,戦略の信頼性を高めます.

戦略的優位性

  • 短期と長期のトレンドを組み合わせて,異なる市場条件に適用できます.
  • カスタム指数とATRを使用し,信号の信頼性を向上させる
  • 複数,空白,または双方向の取引を選択し,異なる取引スタイルに対応できます.
  • デフォルトのパラメータは,感度と安定性のバランスをとるために最適化されています
  • パーソナル・プレファレンスでパラメータを調整し,戦略を最適化できます

戦略的リスクと解決策

  • 戦略に伴うすべてのトレンドは,利回りの危険性がある
  • 多空双方向取引は取引回数や手数料を増加させる可能性がある
  • パラメータを正しく設定しない場合,誤り信号が多すぎる可能性があります.
  • 取引のポジション保持周期を適当に短縮し,利リスクを低減する
  • 取引を減らすために,追加または空白のオプション
  • 十分なテストを行い,パラメータを適切に調整して,パラメータが合理的であることを確認する.

戦略最適化の方向性

  • 単一損失の管理を図るため,損失防止機構を増やす.
  • 他の指標と組み合わせたフィルタリング信号により,誤った取引を減らす
  • 異なるポジション周期パラメータをテストし,最適なパラメータを探します.
  • 機械学習によるパラメータの自動最適化を試みる
  • オーダーフローなどのデータ源を活用する
  • 戦略のコードを最適化し,実行効率を向上させる

要約する

PresentTrend戦略は,全体的に非常に効果的なトレンドフォロー戦略である.それは,短期的および長期的トレンド指標を同時に組み合わせて,感性を保ちながら信号の信頼性を高めます.方向,パラメータを調整し,追加のロジックを追加することにより,この戦略は,異なる市場環境とトレーダーのニーズに適応することができます.トレンドフォロー戦略に固有のリスクに注意を払う必要があるが,全体的にPresentTrendは考慮に値する選択です.

ストラテジーソースコード
/*backtest
start: 2023-08-21 00:00:00
end: 2023-09-20 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PresentTrading

//@version=5

// Define the strategy settings
strategy('PresentTrend - Strategy [presentTrading]' , overlay=true, precision=3, default_qty_type=strategy.cash, 
 commission_value= 0.1, commission_type=strategy.commission.percent, slippage= 1, 
  currency=currency.USD, default_qty_type = strategy.percent_of_equity, default_qty_value = 10, initial_capital= 10000)

// Define the input parameters
priceSource  = input.source(title='Source', defval=hlc3, group='PresentTrend') // The price source to use
lengthParam  = input.int(title='Length', defval=14, group='PresentTrend') // The length of the moving average
multiplier = input.float(title='Multiplier', defval=1.618, step=0.1, group='PresentTrend') // The multiplier for the ATR
indicatorChoice  = input.bool(title='Whether to use RSI or MFI', defval=false, group='PresentTrend') // Whether to use RSI or MFI

// Add a parameter for choosing Long or Short
tradeDirection = input.string(title="Trade Direction", defval="Both", options=["Long", "Short", "Both"])

// Calculate the ATR and the upT and downT values
ATR = ta.sma(ta.tr, lengthParam)
upperThreshold = low - ATR * multiplier 
lowerThreshold  = high + ATR * multiplier 

// Initialize the PresentTrend indicator
PresentTrend = 0.0

// Calculate the PresentTrend indicator
PresentTrend := (indicatorChoice ? ta.rsi(priceSource, lengthParam) >= 50 : ta.mfi(hlc3, lengthParam) >= 50) ? upperThreshold < nz(PresentTrend[1]) ? nz(PresentTrend[1]) : upperThreshold : lowerThreshold > nz(PresentTrend[1]) ? nz(PresentTrend[1]) : lowerThreshold

// Calculate the buy and sell signals
longSignal  = ta.crossover(PresentTrend, PresentTrend[2])
shortSignal  = ta.crossunder(PresentTrend, PresentTrend[2])

// Calculate the number of bars since the last buy and sell signals
barsSinceBuy = ta.barssince(longSignal)
barsSinceSell = ta.barssince(shortSignal)
previousBuy = ta.barssince(longSignal[1])
previousSell = ta.barssince(shortSignal[1])

// Initialize the direction variable
trendDirection = 0

// Calculate the direction of the trend
trendDirection := longSignal and previousBuy > barsSinceSell ? 1 : shortSignal and previousSell > barsSinceBuy ? -1 : trendDirection[1]

// Check the trade direction parameter before entering a trade
if (trendDirection == 1 and (tradeDirection == "Long" or tradeDirection == "Both"))
    strategy.entry("Buy", strategy.long) 
if (trendDirection == -1 and (tradeDirection == "Short" or tradeDirection == "Both"))
    strategy.entry("Sell", strategy.short) 

// Add a stop mechanism when the tradeDirection is one-sided
if (tradeDirection == "Long" and trendDirection == -1)
    strategy.close("Buy")
if (tradeDirection == "Short" and trendDirection == 1)
    strategy.close("Sell")

// Visualization
plot(PresentTrend, color=color.blue, title="PresentTrend")
plotshape(series=longSignal, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal")
plotshape(series=shortSignal, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal")