RVI와 EMA에 기초한 비트코인 거래 전략

저자:차오장, 날짜: 2024-02-22 13:50:17
태그:

img

전반적인 설명

이 전략은 RVI (Relative Vigor Index) 및 EMA (Exponential Moving Average) 지표에 기반합니다. RVI가 엔트리 신호를 주고 빠른 EMA가 느린 EMA보다 높을 때 긴 거리로 이동하고 RVI가 엔트리 신호를 주고 느린 EMA가 빠른 EMA보다 높을 때 짧은 거리로 이동하여 트렌드 및 과잉 구매- 과잉 판매 조건에 기반한 양적 거래 전략을 구현합니다.

전략 원칙

  1. RVI를 사용 하 여 과잉 구매 및 과잉 판매 조건을 판단 합니다. RVI 지표 라인이 신호 라인의 위를 넘을 때, 그것은 긴 갈 과잉 구매 신호입니다. RVI 라인이 신호 라인의 아래를 넘을 때, 그것은 짧은 갈 과잉 판매 신호입니다.

  2. 트렌드 방향을 결정하기 위해 이중 EMA를 사용하십시오. 빠른 EMA가 느린 EMA보다 높을 때 상승 추세입니다. 느린 EMA가 빠른 EMA보다 높을 때 하락 추세입니다.

  3. RVI가 엔트리 신호를 주고 EMA가 상승 추세를 보이는 경우에만 장거리, RVI가 엔트리 신호를 주고 EMA가 하락 추세를 보이는 경우에만 단축.

  4. 장기화 후의 스톱 로스는 최근 최저치 아래로 atr의 거리로 설정됩니다.ATRSL, 그리고 취득은 ATR의 거리를 통해 최근 최고보다 높게 설정됩니다atrTP. 짧은 후에 손실을 멈추는 것은 최근 최고보다atrSL, 그리고 취업이익은 최근 최저치 아래로atrTP.

이점 분석

  1. 트렌드와 과잉 매매를 결합하면 잘못된 파장을 피할 수 있습니다.

  2. 동적인 스톱 로스 및 수익을 취하는 것은 큰 움직임을 잡는 데 도움이 됩니다.

  3. 트렌드 품질과 과잉 구매/ 과잉 판매 수준을 균형을 맞추고 신호의 정확성을 향상시킵니다.

  4. 광범위한 백테스팅, 최적화된 매개 변수, 좋은 실제 거래 성과

위험 분석

  1. EMA가 유동 시장에서 평가하는 빈번한 트렌드 변화는 오버 트레이딩으로 이어질 수 있습니다.

  2. RVI 매개 변수와 EMA 기간은 다른 거래 도구에 최적화되어야 합니다. 그렇지 않으면 성능이 저하 될 수 있습니다.

  3. 스톱 로즈와 수익률 계수는 시장 변동성에 근거하여 합리적으로 설정되어야 합니다. 그렇지 않으면 위험을 효과적으로 통제할 수 없습니다.

최적화 방향

  1. 트렌드 품질을 판단하는 더 많은 지표가 추가 될 수 있습니다. 오시레이터, 볼링거 밴드 등, 거래 결정을 더 정확하게 하기 위해.

  2. 스톱 로스/프로프트 테이크 거리는 ATR와 같은 변동성 측정 기준에 따라 동적으로 조정될 수 있으며, 높은 변동성 기간 동안 더 넓은 스톱을 허용합니다.

  3. 매개 변수 조합은 전략 안정성을 향상시키기 위해 다른 도구에 대해 개별적으로 테스트하고 최적화 할 수 있습니다.

결론

이 전략은 RVI 및 EMA 지표의 강점을 결합하여 주요 트렌드 방향을 존중하면서 과소 구매 / 과소 판매 수준을 판단하고 충돌 트레이드를 피합니다. 역동적 인 스톱 손실 / 수익 취득 메커니즘은 주요 트렌드 방향의 움직임을 파악하는 데 도움이됩니다. 매개 변수 최적화 및 엄격한 위험 통제를 통해이 전략은 비교적 안정적인 수익을 얻을 수 있습니다. 실제 거래 응용 프로그램에서 추가 조정 및 최적화에 대한 여지가 있습니다. 거래자는 자신의 위험 선호도와 도구 특성에 따라 사용자 정의 수정 할 수 있습니다.


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

//this strategy works well on h4 (btc or eth)


//@version=5
strategy(title="Relative Vigor Index", shorttitle="RVGI",overlay=true)
//indicator(title="Relative Vigor Index", shorttitle="RVGI", format=format.price, precision=4, timeframe="", timeframe_gaps=true)
len = input.int(4, title="Length rvi", minval=1)
rvi = math.sum(ta.swma(close-open), len)/math.sum(ta.swma(high-low),len)
sig = ta.swma(rvi)
offset = input.int(0, "Offset rvi", minval = -500, maxval = 500)


atrlength = input.int(19,title="Atr Length",minval=1)
ema1 =  input.int(95,title="Long EMA rapida",minval=1,step=10)
ema2 =  input.int(200,title="Long EMA lenta",minval=1,step=10)

atrSL = input.float(2.0,title="Atr SL", step=0.1)
atrTP = input.float(1.0,title="Atr TP", step=0.1)

atr = ta.atr(atrlength)
esalcista = low > ta.ema(close,ema1) and ta.ema(close,ema1) > ta.ema(close,ema2)
bajista = high < ta.ema(close,ema1) and ta.ema(close,ema1) < ta.ema(close,ema2)


//plot(high + atr)
//plot(low - atr)

//strategy.entry("compra",strategy.long, when=ta.crossover(rvi,sig))
//strategy.close("compra",when=ta.crossunder(rvi,sig))

//plot(rvi, color=#008000, title="RVGI", offset = offset)
//plot(sig, color=#FF0000, title="Signal", offset = offset)
//plotshape(true,style=shape.xcross)

var TP = 0.0
var SL = 0.0

comprado = strategy.position_size>0
vendido = strategy.position_size<0

crucepositivo = ta.crossover(rvi,sig)
crucenegativo = ta.crossunder(rvi,sig)

if comprado
    // ver SL
    if low < SL
        strategy.close("BUY",comment="SL")
        
        
if comprado    
    //ver tp
    if high > TP
        strategy.close("BUY",comment="TP")
        
       
    
    
    
if not comprado and not vendido
    if crucepositivo and esalcista
        strategy.entry("BUY",strategy.long)
        SL := low - (atr * atrSL)
        TP := high + (atr * atrTP)
        alert("BUY",alert.freq_once_per_bar)



//---------------

if vendido
    // ver SL
    if high > SL
        strategy.close("SELL",comment="SL")
        
        
if vendido    
    //ver tp
    if low < TP
        strategy.close("SELL",comment="TP")
        
       

if not vendido and not comprado
    if crucenegativo and bajista
        strategy.entry("SELL",strategy.short)
        SL := high + (atr * atrSL)
        TP := low - (atr * atrTP)
        alert("SELL",alert.freq_once_per_bar)







//----------------

//plotshape(comprado,style=shape.xcross)
plot( comprado ? SL : na, color=color.red,style=plot.style_circles)
plot( comprado ? TP : na, color=color.blue,style=plot.style_circles)

plot( ta.ema(close,ema1),color=color.orange)
plot( ta.ema(close,ema2),color=color.yellow)


plot( vendido ? SL : na, color=color.red,style=plot.style_circles)
plot( vendido ? TP : na, color=color.blue,style=plot.style_circles)


더 많은