ADX + RSI 전략


생성 날짜: 2023-09-27 16:27:39 마지막으로 수정됨: 2023-09-27 16:27:39
복사: 0 클릭수: 2077
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

개요

이것은 ADX와 RSI 지표를 결합한 트렌드 추적 전략이다. 전략은 RSI를 판단하여 과매매 상황을 판단하여 거래 신호를 발송하고, 동시에 ADX를 사용하여 시장 추세를 판단하고, 추세가 보이지 않는 거래를 필터링하여, 흔들리는 시장의 교포를 효과적으로 피할 수 있다.

전략 원칙

  1. 7주기 RSI를 사용하여 과매매를 판단합니다.
  • RSI가 30보다 낮으면 과매매가 됩니다.
  • RSI가 70보다 높으면 과매매로 간주됩니다.
  1. ADX를 사용하여 추세를 판단하는 방법
  • ADX가 30보다 높으면 추세가 뚜렷하다고 볼 수 있습니다.
  • ADX가 30보다 낮으면 추세가 보이지 않는다고 생각하면
  1. 참가 규칙
  • RSI가 30보다 낮고 ADX가 30보다 높을 때 더 많은 것을 할 수 있습니다.
  • RSI가 70보다 높고 ADX가 30보다 높을 때 공백
  1. 정지 손실
  • 선택적인 정지 패스 방식이 있으며, 클로징 정지 패스 또는 진동 정지 패스를 선택할 수 있습니다.
  • 종결 가격에 대한 기준으로 종결을 합니다.
  • 오징어 스톱 스톱 방식은 최근 가격 변동의 최고/최저 지점을 기준으로 합니다.

우위 분석

  1. RSI 지표는 오버 바이 오버 소드를 효과적으로 판단하고, 오버 바이 트랩과 오버 소드 트랩을 줄여줍니다.

  2. ADX 지표는 트렌드가 명확하지 않은 상황을 필터링하여 변동 속의 감옥을 피합니다.

  3. 선택적 제지 손실 방식은 위험을 더 잘 통제할 수 있습니다.

  4. 전략은 간단하고, 이해하기 쉽고, 실행하기 쉬우며, 초보자를 위한 것입니다.

  5. 전략 파라미터를 최적화 할 수있는 넓은 공간은 RSI 주기, 오버 바이 오버 소드 간격, ADX 완화 주기 등의 파라미터를 조정하여 최적화 할 수 있습니다.

위험 분석

  1. RSI 리스크, 오버 바이 오버 셀 신호, 오버 리커션 리커션 리커션

  2. ADX는 트렌드가 지연되어 있고, 트렌드 전환점을 놓칠 수 있다고 판단했습니다.

  3. 부적절하게 설정된 스톱포스트는 손실을 초래할 수 있습니다.

  4. 전략은 단순하고, 과잉 최적화 위험도 있습니다.

  5. 더 나은 효과를 얻기 위해 변수 최적화가 필요합니다.

최적화 방향

  1. RSI의 변수를 최적화하여 오버 바이 오버 소드 간격을 조정하여 최적의 변수 조합을 찾을 수 있습니다.

  2. 다양한 주기의 ADX를 테스트하여 트렌드를 판단하는 최적의 매개 변수를 찾을 수 있습니다.

  3. 다양한 스톱 스톱 손실 방식을 테스트하여 가장 적합한 전략을 찾을 수 있습니다.

  4. 트렌드 필터링을 추가하여 역전 거래를 방지할 수 있습니다.

  5. 다른 지표와 결합하여 전략의 장점을 높일 수 있습니다.

요약하다

이 전략은 RSI와 ADX 두 클래식 지표의 장점을 통합하여 트렌드를 효과적으로 발견하고 흔들림을 피할 수 있으며, 간단한 실용적인 트렌드 추적 전략이다. 전략 최적화 공간은 넓고, 파라미터 조합을 조정하여 더 나은 효과를 얻을 수 있다. 전반적으로 이 전략은 초보자 학습 알고리즘 거래의 입문 전략에 적합하며, 더 복잡한 전략 시스템에 모듈로 통합 할 수 있다.

전략 소스 코드
/*backtest
start: 2023-09-19 00:00:00
end: 2023-09-26 00:00:00
period: 15m
basePeriod: 5m
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/
// © tweakerID

// This is a strategy that uses the 7 Period RSI to buy when the indicator is shown as oversold (OS) and sells when 
// the index marks overbought (OB). It also uses the ADX to determine whether the trend is ranging or trending
// and filters out the trending trades. Seems to work better for automated trading when the logic is inversed (buying OB 
// and selling the OS) wihout stop loss.

//@version=4
strategy("ADX + RSI Strat", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=100, commission_value=0.04, calc_on_every_tick=false)

direction = input(0, title = "Strategy Direction", type=input.integer, minval=-1, maxval=1)
strategy.risk.allow_entry_in(direction == 0 ? strategy.direction.all : (direction < 0 ? strategy.direction.short : strategy.direction.long))


//SL & TP Inputs
i_SL=input(false, title="Use Swing Lo/Hi Stop Loss & Take Profit")
i_SwingLookback=input(20, title="Swing Lo/Hi Lookback")
i_SLExpander=input(defval=0, step=.2, title="SL Expander")
i_TPExpander=input(defval=0, step=.2, title="TP Expander")
i_reverse=input(true, title="Reverse Trades")

//SL & TP Calculations
SwingLow=lowest(i_SwingLookback)
SwingHigh=highest(i_SwingLookback)
bought=strategy.position_size != strategy.position_size[1]
LSL=valuewhen(bought, SwingLow, 0)-((valuewhen(bought, atr(14), 0))*i_SLExpander)
SSL=valuewhen(bought, SwingHigh, 0)+((valuewhen(bought, atr(14), 0))*i_SLExpander)
lTP=strategy.position_avg_price + (strategy.position_avg_price-(valuewhen(bought, SwingLow, 0))+((valuewhen(bought, atr(14), 0))*i_TPExpander))
sTP=strategy.position_avg_price - (valuewhen(bought, SwingHigh, 0)-strategy.position_avg_price)-((valuewhen(bought, atr(14), 0))*i_TPExpander)
islong=strategy.position_size > 0
isshort=strategy.position_size < 0
SL= islong ? LSL : isshort ? SSL : na
TP= islong ? lTP : isshort ? sTP : na

//RSI Calculations
RSI=rsi(close, 7)
OS=input(30, step=5)
OB=input(80, step=5)

//ADX Calculations
adxlen = input(14, title="ADX Smoothing")
dilen = input(14, title="DI Length")
dirmov(len) =>
	up = change(high)
	down = -change(low)
	plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
	minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
	truerange = rma(tr, len)
	plus = fixnan(100 * rma(plusDM, len) / truerange)
	minus = fixnan(100 * rma(minusDM, len) / truerange)
	[plus, minus]
adx(dilen, adxlen) =>
	[plus, minus] = dirmov(dilen)
	sum = plus + minus
	adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
sig = adx(dilen, adxlen)
adxlevel=input(30, step=5)


//Entry Logic
BUY = sig < adxlevel and (RSI < OS) 
SELL = sig < adxlevel and (RSI > OB) 

//Entries
strategy.entry("long", strategy.long, when=i_reverse?SELL:BUY)
strategy.entry("short", strategy.short, when=not i_reverse?SELL:BUY)
//Exits
if i_SL
    strategy.exit("longexit", "long", stop=SL, limit=TP)
    strategy.exit("shortexit", "short", stop=SL, limit=TP)

//Plots
plot(i_SL ? SL : na, color=color.red, style=plot.style_cross, title="SL")
plot(i_SL ? TP : na, color=color.green, style=plot.style_cross, title="TP")
plotshape(BUY ? 1 : na, style=shape.triangleup, location=location.belowbar, color=color.green, title="Bullish Setup")
plotshape(SELL ? 1 : na, style=shape.triangledown, location=location.abovebar, color=color.red, title="Bearish Setup")