ADX 모멘텀 트렌드 전략


생성 날짜: 2024-01-16 15:57:17 마지막으로 수정됨: 2024-01-16 15:57:17
복사: 0 클릭수: 762
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

ADX 모멘텀 트렌드 전략

개요

이 전략은 ADX 지표에 기반하여 시장 추세를 판단하고, DMI 지표에 결합하여 다공간 방향을 판단하고, ADX 기울기를 사용하여 트렌드 강도를 판단하고, ADX 핵심 값을 설정하여 트렌드 아닌 시장을 필터링하고, 이동 평균을 보조하여 거래 신호를 필터링한다.

전략 원칙

  1. ADX, DI+,DI- 지표를 계산한다.
  2. ADX 기울기>0, 추세 증가 표시; 키값은 23로 설정되어, 추세없는 시장을 필터링한다.
  3. DI+는 DI-보다 높으며, 무전력보다 무전력 강함을 나타낸다.
  4. 이동 평균 필터링이 활성화되면, 클로즈 오브 가격이 이동 평균보다 높을 때만 다중 헤드 신호가 발생한다.
  5. ADX 경사가 일 때 평소하면 트렌드가 감소하는 것을 나타냅니다.

우위 분석

  1. 보조 MA 필터링은 비 트렌드 시장의 노이즈 거래를 줄일 수 있다.
  2. ADX 기울기 판단력, 트렌드 발전을 정확하게 판단할 수 있다.
  3. DI 판단 방향은 ADX 판단과 협력하여 비교적 완전한 트렌드 거래 의사 결정 시스템을 형성한다.
  4. 회수와 적자비율은 단순한 이동 평균 전략보다 더 우수할 것으로 보인다.

위험 분석

  1. ADX 지표는 다른 매개 변수를 설정하여 큰 차이를 나타냅니다.
  2. DMI는 아직 완전히 다공 방향이 확정되지 않았기 때문에 잘못된 신호를 보낼 수 있다.
  3. 이 전략의 효율성을 떨어뜨리는 지연이 있다.

최적화 방향

  1. ADX 변수 모음을 최적화하여 최적의 변수를 찾습니다.
  2. 단편적 손실을 막기 위한 전략의 확대를 위한 전략
  3. RSI, 브린 밴드 등과 다른 지표의 필터링 신호를 결합하여 시도하십시오.

요약하다

이 전략은 ADX 판단 트렌드 및 트렌드 강도의 장점을 최대한 활용하고, DMI 지표 판단 방향과 협력하여 전체 트렌드 추적 시스템을 형성한다. 동시에 이동 평균을 보조하는 것은 비 트렌드 시장의 잡음을 효과적으로 필터링 할 수 있다. 변수 최적화 및 지표 조합은 전략의 안정성과 효율성을 더욱 향상시킬 수 있다. 전체적으로, 이 전략은 추세 판단과 방향 판단의 특성을 결합하여 좋은 수익을 얻을 수 있다.

전략 소스 코드
/*backtest
start: 2024-01-08 00:00:00
end: 2024-01-15 00:00:00
period: 10m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © millerrh with inspiration from @9e52f12edd034d28bdd5544e7ff92e 
//The intent behind this study is to look at ADX when it has an increasing slope and is above a user-defined key level (23 default). 
//This is to identify when it is trending.
//It then looks at the DMI levels.  If D+ is above D- and the ADX is sloping upwards and above the key level, it triggers a buy condition.  Opposite for short.
//Can use a user-defined moving average to filter long/short if desried.
// NOTE: THIS IS MEANT TO BE USED IN CONJUNCTION WITH MY "ATX TRIGGER" INDICATOR FOR VISUALIZATION. MAKE SURE SETTINGS ARE THE SAME FOR BOTH.

strategy("ADX | DMI Trend", overlay=true, initial_capital=10000, currency='USD', 
   default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.04)

// === BACKTEST RANGE ===
From_Year  = input(defval = 2019, title = "From Year")
From_Month = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
From_Day   = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
To_Year    = input(defval = 9999, title = "To Year")
To_Month   = input(defval = 1, title = "To Month", minval = 1, maxval = 12)
To_Day     = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
Start  = timestamp(From_Year, From_Month, From_Day, 00, 00)  // backtest start window
Finish = timestamp(To_Year, To_Month, To_Day, 23, 59)        // backtest finish window

// == INPUTS ==
// ADX Info
adxlen = input(14, title="ADX Smoothing")
dilen = input(14, title="DI Period")
keyLevel = input(23, title="Keylevel for ADX")
adxLookback = input(3, title="Lookback Period for Slope")

// == FILTERING ==
// Inputs
useMaFilter = input(title = "Use MA for Filtering?", type = input.bool, defval = true)
maType = input(defval="EMA", options=["EMA", "SMA"], title = "MA Type For Filtering")
maLength   = input(defval = 200, title = "MA Period for Filtering", minval = 1)

// Declare function to be able to swap out EMA/SMA
ma(maType, src, length) =>
    maType == "EMA" ? ema(src, length) : sma(src, length) //Ternary Operator (if maType equals EMA, then do ema calc, else do sma calc)
maFilter = ma(maType, close, maLength)
plot(maFilter, title = "Trend Filter MA", color = color.green, linewidth = 3, style = plot.style_line, transp = 50)

// Check to see if the useMaFilter check box is checked, this then inputs this conditional "maFilterCheck" variable into the strategy entry 
maFilterCheck = if useMaFilter == true
    maFilter
else
    close

// == USE BUILT-IN DMI FUNCTION TO DETERMINE ADX AND BULL/BEAR STRENGTH
[diplus, diminus, adx] = dmi(dilen, adxlen)

buySignal = (adx[0]-adx[adxLookback] > 0) and adx > keyLevel and diplus > diminus  and close >= maFilterCheck
// buySignalValue = valuewhen(buySignal, close, 0)
shortSignal = (adx[0]-adx[adxLookback] > 0) and adx > keyLevel and diplus < diminus  and close <= maFilterCheck
// shortSignalValue = valuewhen(shortSignal, close, 0)
sellCoverSignal = adx[0]-adx[adxLookback] < 0

// == ENTRY & EXIT CRITERIA
// Triggers to be TRUE for it to fire of the BUY Signal : (opposite for the SELL signal).
// (1): Price is over the 200 EMA line. (EMA level configurable by the user)
// (2): "D+" is OVER the "D-" line
// (3): RSI 7 is under 30 (for SELL, RSI 7 is over 70)
// 1* = The ultimate is to have a combination line of 3 EMA values, EMA 14, EMA 50 and EMA 200 - And if price is over this "combo" line, then it's a strong signal

// == STRATEGY ENTRIES/EXITS == 
strategy.entry("Long", strategy.long, when = buySignal)
strategy.close("Long", when = sellCoverSignal)
strategy.entry("Short", strategy.short, when = shortSignal)
strategy.close("Short", when = sellCoverSignal)
    
// == ALERTS == 
// alertcondition(buySignal, title='ADX Trigger Buy', message='ADX Trigger Buy')
// alertcondition(sellSignal, title='ADX Trigger Sell', message='ADX Trigger Sell')