方向性トレンド指数取引戦略


作成日: 2023-09-18 17:07:55 最終変更日: 2023-09-18 17:07:55
コピー: 1 クリック数: 759
1
フォロー
1617
フォロワー

概要

この戦略は,方向トレンド指数 (DTI) を利用して価格トレンドの方向を判断し,トレンドを追跡する取引システムである.DTIは,一定の周期内の最高価格と最低価格の変化方向を比較してトレンドを判断し,上下値の設定で取引信号を生成する.DTIが軌道に乗るときは多し,下下軌道に乗るときは空にする.

戦略原則

ある周期内の最高価格変化と最低価格変化を計算し,価格変化値を得る.価格変化値に複数の指数移動平均を施し,DTI曲線を得る.DTIの上下値を設定し,指標上の値を突破すると多信号,下値を突破すると空信号を生じ,次の信号が現れるまで保持する.

優位分析

  • DTIはトレンドの方向を正確に判断し,信号は少ない.
  • 値フィルターによる無効突破,ノイズ取引を回避
  • 短期的な波動の影響を受けず,継続的にトレンドを追跡する
  • パラメータ調整スペースが広く,反応感度がバランスできる

リスク分析

  • 市場が逆転する時期を正確に判断できず,損失の危険性がある
  • DTI パラメータの設定が不適切で,取引の機会を逃す可能性があります.
  • 長期にわたって持っていたら,もっと大きな引き下げになるかもしれない.
  • 低周波取引は高周波取引には適さない

計算周期を適当に短縮し,値パラメータを調整し,または他の指標と組み合わせてトレンドの逆転を判断する.

最適化の方向

  • DTIの異なるパラメータの組み合わせをテストする
  • DTIの空白を最適化する
  • リスク管理のための ストップ・ロスの策を考える
  • 異なる品種におけるテストパラメータの健壮性

要約する

DTI戦略は,明確な指標信号によってトレンドの方向を判断し,長期にわたって安定した利益を達成することができます.パラメータ最適化などのさらなる改善により,優れたトレンド追跡戦略になることができます.

ストラテジーソースコード
/*backtest
start: 2023-08-18 00:00:00
end: 2023-09-17 00:00:00
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 29/03/2017
// This technique was described by William Blau in his book "Momentum,
// Direction and Divergence" (1995). His book focuses on three key aspects 
// of trading: momentum, direction and divergence. Blau, who was an electrical 
// engineer before becoming a trader, thoroughly examines the relationship between 
// price and momentum in step-by-step examples. From this grounding, he then looks 
// at the deficiencies in other oscillators and introduces some innovative techniques, 
// including a fresh twist on Stochastics. On directional issues, he analyzes the 
// intricacies of ADX and offers a unique approach to help define trending and 
// non-trending periods.
// Directional Trend Index is an indicator similar to DM+ developed by Welles Wilder. 
// The DM+ (a part of Directional Movement System which includes both DM+ and 
// DM- indicators) indicator helps determine if a security is "trending." William 
// Blau added to it a zeroline, relative to which the indicator is deemed positive or 
// negative. A stable uptrend is a period when the DTI value is positive and rising, a 
// downtrend when it is negative and falling. 
//
// You can change long to short in the Input Settings
// Please, use it only for learning or paper trading. Do not for real trading.
////////////////////////////////////////////////////////////
strategy(title="Directional Trend Index (DTI)", shorttitle="DTI")
r = input(14, minval=1)
s = input(10, minval=1)
u = input(5, minval=1)
OS = input(45, minval=1)
OB = input(-45, maxval=-1)
reverse = input(false, title="Trade reverse")
hline(0, color=green, linestyle=line)
xHMU = iff(high - high[1] > 0, high - high[1], 0)
xLMD = iff(low - low[1] < 0, -(low - low[1]), 0)
xPrice = xHMU - xLMD
xPriceAbs = abs(xPrice)
xuXA = ema(ema(ema(xPrice, r),s),u)
xuXAAbs = ema(ema(ema(xPriceAbs, r),s),u)
Val1 = 100 * xuXA
Val2 = xuXAAbs
DTI = iff(Val2 != 0, Val1 / Val2, 0)
pos = iff(DTI > OS, -1,
	     iff(DTI < OB, 1, nz(pos[1], 0))) 
possig = iff(reverse and pos == 1, -1,
          iff(reverse and pos == -1, 1, pos))	   
if (possig == 1) 
    strategy.entry("Long", strategy.long)
if (possig == -1)
    strategy.entry("Short", strategy.short)	   	    
barcolor(possig == -1 ? red: possig == 1 ? green : blue )
plot(DTI, color=maroon, title="DTI")
plot(OB, color=blue, title="OB")
plot(OS, color=red, title="OS")