콤보 트렌드 추적 전략

저자:차오장, 날짜: 2024-01-02 10:41:30
태그:

img

전반적인 설명

콤보 트렌드 추적 전략은 트렌드를 판단하기 위해 이중 지표를 결합하는 양적 거래 전략이다. 먼저 123 역전 지표를 사용하여 가격 역전 신호를 결정하고, 두 개의 확인 주문 신호를 달성하기 위해 방향 트렌드 지표 (DTI) 를 결합하여 가격 트렌드 방향을 판단합니다.

전략 원칙

이 전략은 크게 두 부분으로 구성됩니다.

  1. 123 반전 지표

    123 역전 지표의 판단 원칙은 다음과 같습니다.

    • 클로징 가격이 2일 동안 지속적으로 상승하고 9일 느린 K 라인이 50보다 낮으면, 긴 거래가 됩니다.

    • 닫기 가격이 2일 연속 하락하고 9일 빠른 K 라인이 50보다 높으면, 단축합니다.

    이것은 가격 전환의 시기를 포착할 수 있습니다.

  2. 방향 트렌드 인덱스 (DTI)

    DTI 지표 판단 원칙은: 일정 기간 동안의 절대 가격 변동의 이동 평균을 계산하고, 그 다음 평균 가격 변동에 나눕니다.

    • DTI가 과잉 매수 라인보다 높을 때, 현재는 하락 추세입니다.

    • DTI가 과잉 판매 라인보다 낮으면, 현재는 상승 추세라는 것을 의미합니다.

  3. 조합

    먼저 123 반전 지표를 사용하여 가격 반전 신호가 발생하는지 여부를 결정합니다. 그 다음 DTI 지표와 결합하여 반전 후 전체 트렌드 방향을 결정합니다.

    이것은 반전 신호에만 의존함으로써 발생하는 잘못된 반전 문제를 피하고, 따라서 전략의 안정성과 수익성을 향상시킵니다.

장점

  1. 이중 지표 확인은 잘못된 반전으로 인한 위험을 피합니다.

  2. 역전과 동향을 결합하면 운영 유연성과 안정성 사이의 균형을 이룬다

  3. 큰 매개 변수 최적화 공간, 다양한 품종에 적응하도록 유연하게 조정할 수 있습니다

위험 분석

  1. DTI 매개 변수를 설정하는 것은 경험을 필요로, 부적절한 경향 방향을 잘못 판단합니다

  2. 반전은 반드시 새로운 경향을 나타내지 않습니다. 범위 제한 변동이있을 수 있습니다.

  3. 단일 손실을 통제하기 위해 효과적인 스톱 손실 필요

    솔루션: 매개 변수 최적화 테스트 + 합리적인 스톱 손실 + 다른 지표의 조합

최적화 방향

  1. 최적의 매개 변수 조합을 찾기 위해 DTI 매개 변수를 테스트

  2. 거짓 반전 신호를 필터링하기 위해 다른 표시기를 사용

  3. 스톱 로스 전략을 최적화하고 최적 스톱 로스 포인트를 찾습니다

요약

콤보 트렌드 추적 전략은 가격 반전의 본질성을 효과적으로 결정하고 123 반전과 DTI의 이중 확인을 통해 새로운 트렌드 방향을 캡처하여 전략의 수익성을 향상시킵니다. 그러나 매개 변수 설정 및 스톱 로스 전략은 여전히 전략의 수익 공간을 극대화하기 위해 지속적인 테스트 및 최적화를 필요로합니다. 전반적으로 트렌드 거래와 반전 거래의 장점을 결합하여 권장 할만한 양적 전략입니다.


/*backtest
start: 2023-12-25 00:00:00
end: 2024-01-01 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 19/02/2020
// This is combo strategies for get a cumulative signal. 
//
// First strategy
// This System was created from the Book "How I Tripled My Money In The 
// Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
// The strategy buys at market, if close price is higher than the previous close 
// during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50. 
// The strategy sells at market, if close price is lower than the previous close price 
// during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
//
// Second strategy
// 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. 
//
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
Reversal123(Length, KSmoothing, DLength, Level) =>
    vFast = sma(stoch(close, high, low, Length), KSmoothing) 
    vSlow = sma(vFast, DLength)
    pos = 0.0
    pos := iff(close[2] < close[1] and close > close[1] and vFast < vSlow and vFast > Level, 1,
	         iff(close[2] > close[1] and close < close[1] and vFast > vSlow and vFast < Level, -1, nz(pos[1], 0))) 
	pos

TDI(r,s,u,OS,OB) =>
    pos = 0.0
    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))) 
    pos

strategy(title="Combo Backtest 123 Reversal & Directional Trend Index (DTI)", shorttitle="Combo", overlay = true)
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
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")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posTDI = TDI(r,s,u,OS,OB)
pos = iff(posReversal123 == 1 and posTDI == 1 , 1,
	   iff(posReversal123 == -1 and posTDI == -1, -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)	 
if (possig == 0) 
    strategy.close_all()
barcolor(possig == -1 ? #b50404: possig == 1 ? #079605 : #0536b3 )

더 많은