DMIとHMAの組み合わせ戦略

作者: リン・ハーンチャオチャン,日付: 2024-01-04 17:23:06
タグ:

img

概要

この戦略は,DMIとHull Moving Average (HMA) を組み合わせて,DMIで市場の方向性を特定し,リスク管理なしでHMAでトレンド強さを確認します.

戦略の論理

  1. 真の範囲,DIPlus,DIMinus,ADXを計算する

  2. HMA を計算する.

  3. DIPlus が DIMinus を横切り,HMA が HMA を横切り,HMA が HMA を横切ったとき,ロングエントリをトリガーします.

  4. DIMinusがDIPlusを下回り,HMAがHMAを下回りすると短入りが起動します.

  5. 入力シグナルでロング・ショート・オーダーを

利点分析

トレンドインジケーターDMIとハルMAの二重確認により,市場のトレンドを正確に把握し,ウィップソーを回避できます.リスク管理の欠如は,取引頻度を削減し,長期的には全体的な収益性につながります.

リスク分析

主なリスクは,ストップ損失がないこと,巨大な市場変動が起こると損失を制御できないこと.また,限られた調整スペースと適応性の弱さは欠陥です.

可能な解決策は,移動ストップ損失を追加し,パラメータミックスを最適化することなどです.

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

  1. 真の範囲に基づいて ATR 後ろストップ損失を追加します.

  2. 最適なミックスを見つけるために ハル期間を最適化します

  3. 長/短信号の動的限界値

  4. トレンド継続性を確保するためにモメントフィルターを追加します

概要

DMIとHMAの組み合わせは,トレンドをシンプルかつ効率的に識別するのに優れたパフォーマンスを発揮します.適切なストップ損失とパラメータ調整により,それは素晴らしいトレンドフォローシステムになることができます.


/*backtest
start: 2022-12-28 00:00:00
end: 2024-01-03 00:00:00
period: 1d
basePeriod: 1h
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/
// © Tuned_Official
//@version=4
strategy(title="DMI + HMA - No Risk Management", overlay = false, pyramiding=1, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.025)

//Inputs
hullLen1 = input(title="Hull 1 length", type=input.integer, defval=29)
hullLen2 = input(title="Hull 2 length", type=input.integer, defval=2)
len = input(title="Length for DI", type=input.integer, defval=76)

//Calculations
TrueRange = max(max(high-low, abs(high-nz(close[1]))), abs(low-nz(close[1])))
DirectionalMovementPlus = high-nz(high[1]) > nz(low[1])-low ? max(high-nz(high[1]), 0): 0
DirectionalMovementMinus = nz(low[1])-low > high-nz(high[1]) ? max(nz(low[1])-low, 0): 0

SmoothedTrueRange = 0.0
SmoothedTrueRange := nz(SmoothedTrueRange[1]) - (nz(SmoothedTrueRange[1])/len) + TrueRange
SmoothedDirectionalMovementPlus = 0.0
SmoothedDirectionalMovementPlus := nz(SmoothedDirectionalMovementPlus[1]) - (nz(SmoothedDirectionalMovementPlus[1])/len) + DirectionalMovementPlus
SmoothedDirectionalMovementMinus = 0.0
SmoothedDirectionalMovementMinus := nz(SmoothedDirectionalMovementMinus[1]) - (nz(SmoothedDirectionalMovementMinus[1])/len) + DirectionalMovementMinus

//Indicators
fasthull = hma(close, hullLen1)
slowhull = hma(close, hullLen2)
DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100
DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100
DX = abs(DIPlus-DIMinus) / (DIPlus+DIMinus)*100
ADX = sma(DX, len)

//Plots
plot(DIPlus, color=color.green, title="DI+")
plot(DIMinus, color=color.red, title="DI-")
plot(ADX, color=color.black, title="ADX")

//conditions
go_long = crossover(DIPlus, DIMinus) and fasthull > slowhull //crossover(fasthull, slowhull) and DIPlus > DIMinus
go_short = crossover(DIMinus, DIPlus) and fasthull < slowhull //crossunder(fasthull, slowhull) and DIMinus > DIPlus

//Entry
if strategy.position_size < 0 or strategy.position_size == 0
    strategy.order("long", strategy.long, when=go_long)

if strategy.position_size > 0 or strategy.position_size == 0
    strategy.order("Short", strategy.short, when=go_short)

もっと