방향 지시기 및 선체 이동 평균 조합 전략


생성 날짜: 2024-01-04 17:23:06 마지막으로 수정됨: 2024-01-04 17:23:06
복사: 0 클릭수: 688
avatar of ChaoZhang ChaoZhang
1
집중하다
1621
수행원

방향 지시기 및 선체 이동 평균 조합 전략

개요

이 전략은 이동 지표 ((DMI) 와 헐 이동 평균 ((HMA) 의 조합을 사용하여 DMI를 사용하여 시장 방향을 판단하고 HMA는 트렌드 강도를 확인하여 위험 관리없는 거래를 수행합니다.

전략 원칙

  1. 실제 파도 (True Range), 다중 머리 움직임 지표 (DIPlus), 공중 머리 움직임 지표 (DIMinus) 및 평균 방향 지표 (ADX) 를 계산한다.

  2. 빠른 헐 평균 ((fasthull) 과 느린 헐 평균 ((slowhull) 을 계산한다.

  3. 트리거는 여러 조건으로 이루어집니다: DIPlus에는 DIMinus을 착용하고, fasthull에는 slowhull을 착용한다.

  4. 공백 조건을 유발: DIMinus 아래 DIPlus을 통과하고,fasthull 아래 slowhull을 통과한다.

  5. 다수 공백 조건이 충족되면 각각 다수 공백과 공백 신호를 발산한다.

우위 분석

이 전략은 트렌드를 판단하는 지표인 DMI와 헐 평행선의 이중 확인과 결합하여 시장의 트렌드 방향을 효과적으로 식별할 수 있으며, 다단시장과 공백시장의 반복을 피할 수 있다. 무위험 관리는 거래 빈도를 낮추고, 장기적으로 보면 전반적인 수익 수준이 좋다.

위험 분석

이 전략의 가장 큰 위험은 손실을 막지 않는 설정이며, 시장 상황이 급격하게 변동할 때 손실을 효과적으로 제어 할 수 없습니다. 또한, 매개 변수를 최적화 할 수있는 공간이 제한되어 있으며, 타깃성이 좋지 않은 것도 큰 단점입니다.

이동식 중지, 최적화 변수 조합 등의 방법으로 위험을 줄일 수 있다.

최적화 방향

  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)