방향성 추세 지수 거래 전략


생성 날짜: 2023-09-18 17:07:55 마지막으로 수정됨: 2023-09-18 17:07:55
복사: 1 클릭수: 759
avatar of ChaoZhang ChaoZhang
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")