動的移動平均トレンド取引戦略

作者: リン・ハーンチャオチャン, 日付: 2023年11月15日 17:45:13
タグ:

img

概要

この戦略は,トレードシグナルフィルタリングのためにボリンジャーバンドとRSIを組み合わせたダイナミック・ムービング・アベア指標に基づいています. 長期のみ戦略に従うトレンドを実装します. この戦略は,ハイケン・アシの閉値ダイナミック・ムービング・アベアの変化を計算してトレードシグナルを生成するためにボリンジャーバンドと比較してトレンドを判断します. RSIフィルタを使用して,トレンド追跡のためのトレンド爆発点を効果的に特定することができます.

戦略の論理

この戦略の核心は,ハイケン・アシの閉値ダイナミック・ムービング・平均値の変化を計算することです.具体的には,現在のバーのMAと前2バーのMAの違いを計算し,それを感度係数で掛け算して正確なMA変化値を得ます.

この変化値は,ボリンジャーバンド上帯と下帯の差と比較される.MAの変化がBB差よりも大きい場合,それは"トレンド爆発"とみなされる.爆発が正であるとき,つまりMA変化が正であるとき,それは長い信号と緑色のバーを生成する.爆発が負であるとき,つまりMA変化が負であるとき,それは接近信号と赤いバーを生成する.

さらに,この戦略にはRSIフィルタがあり,RSIが値を下回る場合にのみロング信号を許可し,トレンド逆転のリスクを回避します.

利点

  • 動的MAは,動向変化を効果的に追跡する
  • 動的指標としてBBとMAを組み合わせて,傾向爆発をより正確に識別する
  • RSIフィルターは低いリバウンドからの偽信号を回避します
  • 長期は持続的な牛市に適している
  • 柔軟な調整可能なパラメータ

リスク

  • ダウントレンドから利益を得られない
  • 異なる製品と時間枠に対するパラメータ最適化に過度に依存している
  • トレンド逆転を効果的に捉えることができず,大きな損失につながる可能性があります.
  • RSI フィルターの設定が不適切であれば,取引機会を逃す可能性があります.
  • 高い敏感度で騒々しい取引が起こる

リスク制御方法には,安定性に関する適切なパラメータ調整,傾向の逆転を判断するための他の指標の組み合わせ,明確な長期的傾向でのみ使用などが含まれます.

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

さらに最適化できる余地があります.

  • より良いスムージングのために,閉じる,移動平均等のような異なる価格ソースを試してみましょう.

  • 異なる製品の最適化のために,MAとBB期間のパラメータを調整する

  • より直感的な指標値のための感度係数ではなく比率関係を試す

  • 信号の質を改善するために,トレンドライン,ボリュームなどの他のフィルターを追加

  • 指標パターンに基づく短期戦略を策定する

  • リスク管理の改善のためにストップ・ロスのメカニズムを組み込む

結論

一般的に,これは傾向の方向性を決定するために動的移動平均,爆発点を特定するためにBB,誤った信号をフィルターするためにRSIを使用して,長いトレンドシステムを実現する.しかし,異なる製品とタイムフレームのためのパラメータチューニングを必要とし,ダウントレンドから利益を得ることができないため,いくつかのリスクもあります.より良いパフォーマンスを達成するために,信号品質の向上,ショート戦略の開発,ストップ損失を追加など,さらなる改善の余地があります.


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

//@version=5

///////////Original Script Courtesy of Lazy_Bear.... Absolute Legend\\\\\\\\\\\\\\\

strategy('SmoothedWaddah', overlay=false, initial_capital=1)
sensitivity = input(150, title='Sensitivity')
fastLength = input(20, title='MacD FastEMA Length')
slowLength = input(40, title='MacD SlowEMA Length')
channelLength = input(20, title='BB Channel Length')
mult = input(1.5, title='BB Stdev Multiplier')
RSI14filter = input(40, title='RSI Value trade filter')

////////////MacD Calculation of price//////////////////////////////
calc_macd(source, fastLength, slowLength) =>
    fastMA = ta.ema(source, fastLength)
    slowMA = ta.ema(source, slowLength)
    fastMA - slowMA

/////////BolingerBand Calculation of Price///////////////////////
calc_BBUpper(source, length, mult) =>
    basis = ta.sma(source, length)
    dev = mult * ta.stdev(source, length)
    basis + dev

calc_BBLower(source, length, mult) =>
    basis = ta.sma(source, length)
    dev = mult * ta.stdev(source, length)
    basis - dev

//////heinkenashi chart call for closing price "smoothing mechanism"\\\\\\\\\\\\\\\\\\\\\\\\\\\
point = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)

////////////////////T1 is change in MacD current  candle from previous candle Sensitivy amplifies calculation/////////////////////
t1 = (calc_macd(point, fastLength, slowLength) - calc_macd(point[1], fastLength, slowLength)) * sensitivity
//////////////////////T2 is  T1 from two candles prior\\\\\\\\\\\\\\\\\\\\\\\\\\\
t2 = (calc_macd(point[2], fastLength, slowLength) - calc_macd(point[3], fastLength, slowLength)) * sensitivity

////////////////E1 is difference in bolinger band upper and lower...E2 is E1 from one candle prior not needed//////////////
e1 = calc_BBUpper(ohlc4, channelLength, mult) - calc_BBLower(ohlc4, channelLength, mult)
//e2 = (calc_BBUpper(close[1], channelLength, mult) - calc_BBLower(close[1], channelLength, mult))

//////signal bar printing.. Up if MacD positive .. Down if MacD negative//////////
trendUp = t1 >= 0 ? t1 : 0
trendDown = t1 < 0 ? -1 * t1 : 0

///////plots difference in macD*Sensitivity, color change if increasing or decreasing. 
//////color is green/lime if explosion is up \ color is red/orange if explosion is down/////////
plot(trendUp, style=plot.style_columns, linewidth=1, color=trendUp < trendUp[1] ? color.new(color.lime,45) : color.new(color.green,45), title='UpTrend')
plot(trendDown, style=plot.style_columns, linewidth=1, color=trendDown < trendDown[1] ? color.new(color.orange,45) : color.new(color.red,45), title='DownTrend')
plot(e1, style=plot.style_line, linewidth=2, color=color.new(#A0522D, 0), title='ExplosionLine')


////////////Entry conditions and Concept/////////////////////
////////////Long Only System. T1 is measuring the distance between MACD EMA's. This is Multiplied
////////////by the sensitivity so that it can be compared to the difference between BollingerBand. 
/////////////{this could have been a ratio maybe i will work with that in a different script.} 
/////////////I found that 135-175 sensitivy allows for values to be compared on most charts.....
////////////If the (difference between the EMA)*(Sensitivity) is greater than (BB upper line- BB lower line)
////////////it is considered an explosion in either the downside or the upside.The indicator will print
///////////a bar higher than the trigger line either green or red (up or down respectively)//////////////////

longCondition = trendUp > e1 and ta.rsi(close, 14) > RSI14filter
if longCondition
    strategy.entry('up', strategy.long)

strategy.close('up', trendDown > e1)



もっと