作者: リン・ハーンチャオチャン,日付: 2024-01-23 11:31:14
タグ:

img

概要

この戦略は,適応傾向フォローを達成するために,平均真の範囲 (ATR),相対強度指数 (RSI) とトライリングストップ損失を組み合わせます.動的ストップ損失は,市場の変動を反映するためにATRによって計算され,RSIはトレンド方向を特定し,トライリングストップ損失は利益を最大化するために価格変動を追跡します.これは非常に典型的なトレンドフォロー戦略です.

原則

  1. ATRを計算します.ATRは市場の変動とリスクレベルを示します.この戦略は,適応リスク管理のために動的ストップ損失を計算するためにATRを使用します.

  2. RSIを計算する.RSIは過買い/過売状態を判断する.RSIが50を超えると上昇見通し,50を下回ると下落見通しを示します.この戦略はRSIを使用してトレンド方向を決定します.

  3. トレイリングストップ損失追跡.ATRによって計算されたストップ損失レベルとRSIによるトレンド方向に従って,この戦略は,効果的なストップ損失を保証しながら利益を最大化するために,価格変動を追跡するためにストップ損失を移動し続けます.

  4. 50を下回ると短縮します. そして,トレンドに沿って利益をロックするために,ATRに基づいてストップ損失を移動します.

利点分析

  1. ATR アダプティブ・ストップ・ロスは市場の変動を考慮し,あまりにも広いストップ・ロスを避ける.

  2. RSIは信頼性の高い傾向を特定し 挫折を回避します

  3. ストップ・ロスは 利益目標の拡大傾向にある

リスク分析

  1. ATRとRSIのパラメータはバックテストの最適化が必要で,そうでなければ戦略のパフォーマンスに影響します.

  2. ストップ・ロスの保護では,ストップ・ロスを突破する急激な価格急上昇のリスクは依然として存在します. リスクを制御するためにポジションサイズを検討することができます.

  3. 戦略のパフォーマンスは,異なる製品に対するパラメータ調整に大きく依存します.

強化

  1. 適応性パラメータ最適化のための機械学習アルゴリズムを考慮してください.

  2. ストップ・ロスの浸透確率を減らすため,市場の状況に基づいて動的調整のためのポジションサイズ制御を追加します.

  3. トレンドの逆転点を見逃さないように,より多くの傾向指標を追加します.

結論

この戦略は,ATR,RSIとトライリングストップロスを統合し,典型的な適応型トレンドフォローシステムです.パラメータチューニングを通じて,異なる取引製品に柔軟に適応することができ,推奨される普遍的なトレンドフォロー戦略です.より多くの判断と機械学習最適化により,さらに優れたパフォーマンスを達成することができます.


/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-19 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy(title="UTBot Strategy", 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 -
// CREDITS to @TradersAITradingPlans for making this Strategy. 
// Strategy fixed with Time period by Kirk65.
// I am using this UT bot with 2 hours time frame with god resultss. Alert with "Once per bar" and stoploss 1.5%. If Alerts triggered and price goes against Alert. Stoploss will catch it. Wait until next Alert.
// While @Yo_adriiiiaan mentions it works best on a 4-hour timeframe or above, witch is a lot less risky, but less profitable. 

testStartYear = input(2019, "BACKTEST START YEAR", minval = 1980, maxval = 2222) 
testStartMonth = input(01, "BACKTEST START MONTH", minval = 1, maxval = 12)
testStartDay = input(01, "BACKTEST START DAY", minval = 1, maxval = 31)
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)
testStopYear = input(2222, "BACKTEST STOP YEAR", minval=1980, maxval = 2222)
testStopMonth = input(12, "BACKTEST STOP MONTH", minval=1, maxval=12)
testStopDay = input(31, "BACKTEST STOP DAY", minval=1, maxval=31)
testPeriodStop = timestamp(testStopYear, testStopMonth, testStopDay, 0, 0)

testPeriod = true

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, when=testPeriod)
if (sell)
    strategy.entry("UTBotSell",strategy.short, when=testPeriod)

もっと