トレンドトラッキング戦略 適応型トレーリングストロスの多因子モデルに基づく

作者: リン・ハーンチャオチャン開催日:2023年12月19日 11:04:27
タグ:

img

概要

この戦略は,適応的なトレーリングストロスのマルチファクターモデルによって駆動されるトレンド追跡戦略である.RSI,MACD,ストキャスティックスなどの複数の指標を組み込み,トレンド方向を決定するマルチファクターモデルを構築する.一方,リスク制御を実現するためにATRに基づいてストロスの価格を動的に調整する適応的なトレーリングストロスのメカニズムを備えています.

原則

この戦略は,トレンドを判断するためのモデルを構築するために複数の指標を活用する.まず,RSIとMACDを組み合わせてトレンド方向を決定する.その後,ストーキャスティックを使用して過剰なオーバー買いまたはオーバーセールシグナルをフィルターする.注文を入力した後,ATRを使用してリスクパラメータを計算し,適応ストップロスを実装する.

RSIが52を超えると購入信号を生成し,MACDのゴールデンクロスが発生すると販売信号を生成する.RSIが48を下回るとMACDデッドクロスが発生すると販売信号を生成する.偽信号をフィルタリングするために,ストキャストシグナルがオーバーバイトまたはオーバーセールされているかどうかを検出する.ストップロスの場合は,アダプティブストップロスのリスクを効果的に制御できるATRに基づいてパラメータを計算する.

利点

この戦略の最大の利点は,強力なリスク制御能力にあります.多要素モデルでトレンド方向を判断することで,いくつかのノイズをフィルターし,信号品質を改善することができます.一方,適応型ストップロスのメカニズムは,単一の損失を効果的に制御するために,市場の変動に基づいてストップロスの範囲を調整することができます.

また,この戦略のパラメータは,バックテストの結果が良好で合理的に設定されています.パラメータチューニングを通じて異なるサイクル資産の最適化を達成できます.パラメータ最適化によってより多くの市場環境に適合することができます.

リスク

この戦略の主なリスクは,多要素モデル構築の質である.モデルがトレンドを効果的に決定できなければ,大規模な偽信号を生成する.また,ストップロスの戦略は,本質的に狩られるリスクを負う.

これらのリスクを軽減するために,モデルの重量を調整し,パラメータ設定を最適化し,他のストップロスの戦略と組み合わせることなどの側面から改善を行うことができます. 異常な市場が発生した場合に手動介入も必要です.

オプティマイゼーションの方向性

この戦略は,次の側面から最適化できます.

  1. 多因子モデルにおける指標の重さを調整し,最適な組み合わせを見つける

  2. CCI,波動性などのより多くの指標をテストし,多要素モデルを豊かにします

  3. より多くの製品とサイクルに合うようにパラメータ設定を最適化します

  4. 最適な組み合わせを見つけるために異なるストップロスの戦略を試してみましょう

  5. 機械学習ドライブを可能にするためにモデルトレーニングと戦略評価モジュールを追加

概要

この戦略は,トレンド判断とリスク管理の有機的な組み合わせを達成するために,多要素モデルと適応性ストップロスのメカニズムを統合している.バックテストの結果とスケーラビリティは良好である.継続的な最適化により,長期保有に価値のある定量戦略になることができる.


/*backtest
start: 2022-12-12 00:00:00
end: 2023-12-18 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy(title="TradersAI_UTBot", overlay = true)
// CREDITS to @HPotter for the orginal code. 
// CREDITS to @Yo_adriiiiaan for recently publishing the UT Bot study based on the original code - 
// I just added some simple code to turn it into a strategy so that you all can backtest it to see the results for yourself! 
// Use this strategy on your favorite instrumnet and timeframe, with your favorite settings
// While @Yo_adriiiiaan mentions it works best on a 4-hour timeframe or above, 
// I am  happy to share here this working on a 15-minute chart on e-mini S&P 500 Index (using the KeyValue setting at 10)
// I am sure different people would discover different settings that work best for their preferred instrumnet/timeframe etc. 
// Play with it and enjoy! And, don't forget to share any positive results you might get! Good luck with your trading!

SOURCE = input(hlc3)
RSILENGTH = input(14, title = "RSI LENGTH")
RSICENTERLINE = input(52, title = "RSI CENTER LINE")
MACDFASTLENGTH = input(7, title = "MACD FAST LENGTH")
MACDSLOWLENGTH = input(12, title = "MACD SLOW LENGTH")
MACDSIGNALSMOOTHING = input(12, title = "MACD SIGNAL SMOOTHING")
a = input(10, title = "Key Vaule. 'This changes the sensitivity'") 
SmoothK = input(3)
SmoothD = input(3)
LengthRSI = input(14)
LengthStoch = input(14)
RSISource = input(close) 
c = input(10, title="ATR Period")
xATR = atr(c)
nLoss = a * xATR
xATRTrailingStop = iff(close > nz(xATRTrailingStop[1], 0) and close[1] > nz(xATRTrailingStop[1], 0), max(nz(xATRTrailingStop[1]), close - nLoss),
     iff(close < nz(xATRTrailingStop[1], 0) and close[1] < nz(xATRTrailingStop[1], 0), min(nz(xATRTrailingStop[1]), close + nLoss), 
     iff(close > nz(xATRTrailingStop[1], 0), close - nLoss, close + nLoss)))
pos =	iff(close[1] < nz(xATRTrailingStop[1], 0) and close > nz(xATRTrailingStop[1], 0), 1,
     iff(close[1] > nz(xATRTrailingStop[1], 0) and close < nz(xATRTrailingStop[1], 0), -1, nz(pos[1], 0))) 
color = pos == -1 ? red: pos == 1 ? green : blue 
ema= ema(close,1)
above = crossover(ema,xATRTrailingStop )
below = crossover(xATRTrailingStop,ema)
buy = close > xATRTrailingStop and above 
sell = close < xATRTrailingStop and below
barbuy = close > xATRTrailingStop 
barsell = close < xATRTrailingStop 
plotshape(buy, title = "Buy", text = 'Buy', style = shape.labelup, location = location.belowbar, color= green,textcolor = white, transp = 0, size = size.tiny)
plotshape(sell, title = "Sell", text = 'Sell', style = shape.labeldown, location = location.abovebar, color= red,textcolor = white, transp = 0, size = size.tiny)
barcolor(barbuy? green:na)
barcolor(barsell? red:na)
alertcondition(buy, title='Buy', message='Buy')
alertcondition(sell, title='Sell', message='Sell')

if(buy)
    strategy.entry("UTBotBuy",strategy.long)
if(sell)
    strategy.entry("UTBotSell",strategy.short)

もっと