양적 추세 추적 전략

저자:차오장, 날짜: 2024-02-01 11:42:22
태그:

img

전반적인 설명

이 전략은 시장 트렌드를 판단하기 위해 볼링거 밴드, RSI, ADX, MACD와 같은 여러 지표를 채택하고 강력한 트렌드 식별 능력을 가지고 있습니다. 지표 신호가 동시에 상승할 때 트렌드 다음 전략을 취합니다. 지표 신호가 동시에 하락할 때 지점을 폐쇄하여 손실을 중지합니다.

전략 원칙

  • 볼링거 대역을 사용하여 가격이 상단 또는 하단 레일 근처에 있는지 판단하여 추세가 형성되는지 결정합니다.
  • RSI 지표와 결합하여 오버구입 및 오버 판매 영역을 피하고 거짓 브레이크를 방지합니다.
  • ADX를 사용하여 트렌드 강도를 결정하고 트렌드 강도가 강한 경우에만 신호를 보내십시오.
  • 단기 및 장기 트렌드의 일관성을 판단하기 위해 MACD를 채택하십시오.
  • 오버나이트 리스크를 피하기 위한 거래 세션 제한

여러 지표의 결합 판단을 통해 가격 추세를 정확하게 파악하고 추세가 발생하면 과도한 수익을 달성하기 위해 적시에 추적 할 수 있습니다.

이점 분석

이 전략의 가장 큰 장점은 더 포괄적이고 정확한 지표 조합 판단으로 가격 동향을 효과적으로 파악하고 단일 지표로 인한 잘못된 신호를 피할 수 있다는 것입니다.

특히 이점은 다음과 같습니다.

  1. 볼링거 밴드는 가격 변동 범위와 강도를 결정할 수 있습니다.
  2. RSI는 과반 매매 지역에서 구매하고 과반 매매 지역에서 판매하는 것을 피합니다.
  3. ADX는 트렌드 강도를 결정합니다. 강한 트렌드만 따릅니다.
  4. MACD는 단기 및 장기간의 일관성을 판단합니다.
  5. 오버나이트 리스크를 피하기 위한 거래 세션 제한

지표 조합 판단을 통해 잘못된 신호를 극대화하고 전략의 안정성을 향상시킬 수 있습니다.

위험 분석

이 전략의 주요 위험은 다음과 같습니다.

  1. 지표가 고장나는 시장 사건
  2. 범위에 제한된 시장에서 빈번한 잘못된 신호

위험 1의 경우, 여러 지표에 의존하는 것은 단일 지표의 실패 문제를 어느 정도 완화시킬 수 있지만, 위험 관리 메커니즘은 여전히 개선되어야합니다.

리스크 2의 경우 매개 변수를 좁은 거래 범위에 적절히 조정하고 위험을 완화하기 위해 거래 빈도를 줄일 수 있습니다.

최적화 방향

이 전략의 최적화 가능한 주요 측면은 다음과 같습니다.

  1. 너무 깊게 철수하지 않도록 후속 스톱 손실, 시간 스톱 손실, 브레이크오웃 스톱 손실 등과 같은 스톱 손실 메커니즘을 추가하십시오.
  2. 최적화 매개 변수, 최적의 표시 매개 변수 조합을 조정
  3. 부피 필터와 같은 필터를 추가하여 낮은 부피에서 잘못된 브레이크를 피합니다.
  4. 신호 정확성을 향상시키기 위해 KDJ, OBV와 같은 더 많은 지표를 통합하십시오.
  5. 매개 변수를 자동 최적화하기 위해 기계 학습 방법을 채택

지속적인 최적화를 통해 매개 변수 안정성을 지속적으로 향상시키고 잘못된 신호의 확률을 줄이십시오.

요약

전체적으로 이 전략은 가격 동향을 효과적으로 식별할 수 있는 지표 조합 판단을 통해 경향 신호를 식별하는 상대적으로 강한 능력을 가지고 있습니다.

그러나 또한 특정 위험, 위험 관리 및 매개 변수 최적화는 안정적인 장기 운영을 위해 지속적으로 개선되어야합니다. 매개 변수 자동 최적화를 달성하기 위해 기계 학습과 같은 방법이 나중에 도입 될 수 있다면 전략의 견고성과 수익성을 크게 향상시킬 것입니다.


/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 00:00:00
period: 5h
basePeriod: 15m
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/
// © abilash.s.90


dIMinusCalc(adxLen) =>
    
    smoothedTrueRange = 0.0
    smoothedDirectionalMovementMinus = 0.0
    dIMinus = 0.0
    trueRange = 0.0
    directionalMovementMinus = 0.0
    
    trueRange := max(max(high-low, abs(high-nz(close[1]))), abs(low-nz(close[1])))
    directionalMovementMinus := nz(low[1])-low > high-nz(high[1]) ? max(nz(low[1])-low, 0): 0
    
    smoothedTrueRange := nz(smoothedTrueRange[1]) - (nz(smoothedTrueRange[1])/adxLen) + trueRange
    smoothedDirectionalMovementMinus := nz(smoothedDirectionalMovementMinus[1]) - (nz(smoothedDirectionalMovementMinus[1])/adxLen) + directionalMovementMinus
    
    dIMinus := smoothedDirectionalMovementMinus / smoothedTrueRange * 100
    
    dIMinus

dIPlusCalc(adxLen) =>
    
    smoothedTrueRange = 0.0
    smoothedDirectionalMovementPlus = 0.0
    dIPlus =  0.0
    trueRange = 0.0
    directionalMovementPlus = 0.0
    
    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
    
    smoothedTrueRange := nz(smoothedTrueRange[1]) - (nz(smoothedTrueRange[1])/adxLen) + trueRange
    smoothedDirectionalMovementPlus := nz(smoothedDirectionalMovementPlus[1]) - (nz(smoothedDirectionalMovementPlus[1])/adxLen) + directionalMovementPlus
    
    dIPlus := smoothedDirectionalMovementPlus / smoothedTrueRange * 100
    
    dIPlus
    
    
Adx(adxLen) =>
    dIPlus =  0.0
    dIMinus = 0.0
    dX = 0.0
    aDX = 0.0
    dIPlus := dIPlusCalc(adxLen)
    dIMinus := dIMinusCalc(adxLen)
    dX := abs(dIPlus-dIMinus) / (dIPlus+dIMinus)*100
    aDX := sma(dX, adxLen)
    
    aDX
    
BarInSession(sess) => time(timeframe.period, sess) != 0


//@version=4
strategy("Bollinger Band + RSI + ADX + MACD", overlay=true)

//Session

session = input(title="Trading Session", type=input.session, defval="0930-1500")

sessionColor = BarInSession(session) ? color.green : na

bgcolor(color=sessionColor, transp=95)

// Bollinger Bands
src = input(high, title="Bollinger Band Source", type=input.source)
length = input(3, minval=1, type=input.integer, title="Bollinger Band Length")
mult = input(4.989, minval=0.001, maxval=50, step=0.001, type=input.float, title="Bollinger Band Std Dev")
basis = sma(src, length)
dev = mult * stdev(src, length)
upper = basis + dev
lower = basis - dev


plot(upper, title="Bollinger Band Upper", color=color.red)
plot(lower, title="Bollinger Band Lower", color=color.green)

// RSI
rsiSrc = input(close, title="RSI Source", type=input.source)
rsiLength = input(16, minval=1, type=input.integer, title="RSI Length")
rsiComparator = input(39.2, title="RSI Comparator", type=input.float, step=0.1)

rsi = rsi(rsiSrc, rsiLength)

// ADX
adxLength = input(14, minval=1, type=input.integer, title="ADX Length")
adxComparator = input(14, minval=1, type=input.integer, title="ADX Comparator")

adx = Adx(adxLength)

// Heikinashi

haClose = security(heikinashi(syminfo.ticker), timeframe.period, close)
haOpen = security(heikinashi(syminfo.ticker), timeframe.period, open)

nextHaOpen = (haOpen + haClose) / 2

//MACD

macdCalcTypeProcessed = input(title="MACD Source", type=input.source, defval=high)
fast = input(12, title="MACD Fast")
slow = input(20, title="MACD Slow")
signalLen = input(15, title="MACD Signal")

fastMA = ema(macdCalcTypeProcessed, fast)
slowMA = ema(macdCalcTypeProcessed, slow)
macd = fastMA - slowMA
signal = sma(macd, signalLen)



longCondition() =>
    (low < lower) and (rsi[0] > rsiComparator) and (adx > adxComparator) and (close > nextHaOpen) and BarInSession(session) and macd > signal

stop = (close - max((low - (low * 0.0022)), (close - (close * 0.0032)))) / syminfo.mintick
target = (max(upper, (close + (close * 0.0075))) - close) / syminfo.mintick


strategy.entry("SX,LE", strategy.long, when=longCondition(), comment="SX,LE")
strategy.close_all(when=(not BarInSession(session)))
strategy.exit("LX", from_entry="SX,LE", profit=target, loss=stop)


더 많은