RVI와 EMA를 기반으로 한 비트코인 ​​거래 전략


생성 날짜: 2024-02-22 13:50:17 마지막으로 수정됨: 2024-02-22 13:50:17
복사: 0 클릭수: 776
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

RVI와 EMA를 기반으로 한 비트코인 ​​거래 전략

개요

이 전략은 RVI ((상대 강도 지수) 와 EMA ((지수 이동 평균) 두 지표에 기반을 두고 있다. RVI가 이윤을 내면, 빠른 EMA가 느린 EMA 위에 상장하고, 느린 EMA가 빠른 EMA 위에 상장하여, 추세와 과매매를 기반으로 한 양적 거래 전략을 구현한다.

전략 원칙

  1. RVI를 사용하여 과매매를 판단한다. RVI 지표선 상에서 신호선을 통과할 때 과매매 신호를 위해 과매매를 한다. RVI 지표선 아래에서 신호선을 통과할 때 과매매 신호를 위해 공백을 만든다.

  2. 쌍 EMA를 사용하여 트렌드 방향을 판단한다. 빠른 EMA가 느린 EMA 위에 있을 때 부진 트렌드이며, 느린 EMA가 빠른 EMA 위에 있을 때 하향 트렌드이다.

  3. RVI가 이윤을 허용하고 EMA가 낙점으로 판단했을 때만 다중 거래가 이루어집니다. RVI가 이윤을 허용하고 EMA가 낙점으로 판단했을 때만 공백 거래가 이루어집니다.

  4. 이 경우, 이 값은 0이 됩니다.*atrSL 거리, 막대기가 가장 가까운 고도 위에 있다atr*atrTP 거리; 코오피 후의 스톱 손실이 가장 가까운 고위점 위에 있습니다.*atrSL 거리, 정지점은 가장 가까운 최저점 아래atr*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)