스윙 듀얼 이동 평균 및 RSI 크로스오버 전략

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

img

이 전략은 이중 이동 평균과 RSI 지표를 통합하여 긴 지점과 짧은 지점 사이의 교차 거래 전략을 구성합니다. 단기 지표와 불필요한 소음 거래를 피하면서 중장기 트렌드를 포착 할 수 있습니다.

전략 논리

이 전략은 빠른 이동 평균 (EMA 59 및 EMA 82) 및 느린 이동 평균 (EMA 96 및 EMA 95) 으로 구성된 두 개의 이동 평균 세트를 채택합니다. 가격이 빠른 EMA를 넘을 때 길고 가격이 빠른 EMA를 넘을 때 짧습니다. 한편, RSI 지표의 과잉 구매 및 과잉 판매 영역은 거래 신호 및 스톱-로스를 확인하는 데 사용됩니다.

특히, 빠른 EMA가 느린 EMA를 넘을 때 긴 신호가 생성됩니다. 이 시점에서 RSI가 30 (가장 팔린 영역) 이면, 긴 이동. 빠른 EMA가 느린 EMA를 넘을 때 짧은 신호가 생성됩니다. 이 시점에서 RSI가 70 (가장 팔린 영역) 을 넘으면 짧은 이동.

이중 이동 평균을 사용하는 것의 장점은 중장기 트렌드의 변화를 더 잘 인식하는 것입니다. RSI는 가짜 브레이크오웃에서 약간의 소음 거래를 필터합니다.

장점

  • 이중 이동 평균으로 중장기 동향을 파악합니다.
  • RSI 지표와 함께 필터 노이즈 거래
  • 트렌드를 따르는 것과 평균 리버션 거래를 결합합니다
  • 단순하고 명확한 논리

위험 분석

  • 주로 범위에 묶인 시장에서, 이동 평균 신호는 윙사 (whipsaws) 의 대상이 될 수 있습니다.
  • RSI 지표도 특정 시장 조건에서 실패합니다.
  • 스톱 로스 배치는 너무 느슨하거나 너무 단단하지 않도록 신중해야 합니다.

개선 영역

  • 더 긴 사이클 이동 평균 조합을 테스트
  • 다른 매개 변수 조정 예를 들어 RSI 과잉 구매 / 과잉 판매 영역의 문턱을 시도
  • 거래량과 같은 추가 필터를 추가합니다
  • 스톱 손실 전략을 최적화하고, ATR와 동적 스톱 손실을 통합합니다.

요약

이 전략은 이중 이동 평균과 RSI 지표의 평균 반전 거래의 추세를 통합합니다. 이중 EMA는 중장기 트렌드 방향을 추적하며, RSI는 거래 신호의 유효성과 스톱 로스를 확인합니다. 이것은 길고 짧은 간 간단하고 실용적인 크로스오버 전략입니다. 매개 변수 조정 및 최적화로 다른 시장 환경에 적응 할 수 있습니다.


/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy("Swing Hull/rsi/EMA Strategy", overlay=true,default_qty_type=strategy.cash,default_qty_value=10000,scale=true,initial_capital=10000,currency=currency.USD)

//A Swing trading strategy that use a combination of indicators, rsi for target, hull for overall direction enad ema for entering the martket.
// hull ma copied from syrowof HullMA who copied from mohamed982 :) thanks both
// Performance 

n=input(title="period",defval=500)

n2ma=2*wma(close,round(n/2))
nma=wma(close,n)
diff=n2ma-nma
sqn=round(sqrt(n))

n2ma1=2*wma(close[1],round(n/2))
nma1=wma(close[1],n)
diff1=n2ma1-nma1
sqn1=round(sqrt(n))

n1=wma(diff,sqn)
n2=wma(diff1,sqn)
c=n1>n2?green:red
ma=plot(n1,color=c)



// RSi and Moving averages

length = input( 14 )
overSold = input( 70)
overBought = input( 30)
point = 0.0001
dev= 2

fastLength = input(59)
fastLengthL = input(82)
slowLength = input(96)
slowLengthL = input(95)
price = close

mafast = ema(price, fastLength)
mafastL= ema(price, fastLengthL)
maslow = ema(price, slowLength)
maslowL = ema(price, slowLengthL)
vrsi = rsi(price, length)
cShort =  (crossunder(vrsi, overBought))

condDown = n2 >= n1
condUp = condDown != true
closeLong =  (crossover(vrsi, overSold))
closeShort = cShort 


// Strategy Logic
longCondition = n1> n2
shortCondition = longCondition != true

col =condUp ? lime : condDown ? red : yellow
plot(n1,color=col,linewidth=3)


if (not na(vrsi))
    if shortCondition    
        if (price[0] < maslow[0] and price[1] > mafast[1]) //cross entry
            strategy.entry("SYS-SHORT", strategy.short, comment="short")
strategy.close("SYS-SHORT", when=closeShort) //output logic

if (not na(vrsi))
    if longCondition // swing condition          
        if (price[0] < mafast[0] and price[1] > mafast[1]) //cross entry
            strategy.entry("SYS-LONG", strategy.long, comment="long")
strategy.close("SYS-LONG", when=closeLong) //output logic


// Stop Loss 


sl = input(75)
Stop = sl * 10
Q = 100


strategy.exit("Out Long", "SYS-LONG", qty_percent=Q, loss=Stop)
strategy.exit("Out Short", "SYS-SHORT", qty_percent=Q, loss=Stop)



//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)

더 많은