戦略をフォローする傾向

作者: リン・ハーンチャオチャン開催日:2023年9月21日15時08分
タグ:

概要

PresentTrend戦略は,独自のカスタムトレンドフォロー戦略である.この組み合わせにより,戦略は短期的および長期的市場トレンドの両方を利用することができ,さまざまな市場条件に適している.

働き方

戦略は2つの部分からなる.

  1. カスタムRSIまたはMFI指標:この指標は,RSIまたはMFIに基づいて現在のトレンド値を計算し,そのクロスオーバーとクロスアンダーに基づいて購入および販売信号を生成し,潜在的なトレンド逆転を示します.

  2. ATR インディケーター (ATR indicator): トレンドをフォローする一般的なインディケーターで,平均真差 (Average True Range,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")


もっと