RSI 기반의 자동 거래 전략

저자:차오장, 날짜: 2024-02-29 14:14:01
태그:

img

전반적인 설명

이 전략은 RSI 지표에 기반한 긴 포지션과 짧은 포지션 모두를 위한 자동화 거래 시스템을 설계합니다. RSI가 과반 구매 또는 과반 판매 수준을 보여주면 트레이드를 입력하고 특정 조건으로 유발된 스톱 손실로 종료합니다.

전략 논리

이 전략은 RSI 지표를 사용하여 과잉 구매 / 과잉 판매 시장 조건을 식별합니다. 구체적으로, RSI가 과잉 판매 라인 아래로 떨어지면 긴 포지션에 진입합니다. RSI가 과잉 구매 라인을 초과하면 짧은 포지션에 진입합니다.

또한, 출구 규칙은 전략에 설정되어 있습니다. 긴 포지션을 열면 RSI가 다시 과소매 라인을 넘어서면, 긴 포지션을 닫기 위해 스톱 손실을 유발합니다. 마찬가지로, 쇼트를 열고, RSI가 다시 과소매 라인을 넘어서면, 쇼트를 닫습니다.

이점 분석

이 전략의 가장 큰 장점은 RSI 지표를 사용하여 양적 거래에서 비교적 성숙하고 신뢰할 수있는 기술 분석 방법인 과잉 구매 / 과잉 판매 시나리오를 판단하는 것입니다. 간단한 이동 평균 전략에 비해이 전략은 시장 전환점을 더 정확하게 파악하여 거래 시스템의 수익 잠재력을 증가시킬 수 있습니다.

또한, 스톱 로스 메커니즘은 강력한 일방 트렌드 중에 하향 위험을 효과적으로 제어합니다. 이는 달리기가 쉽게 곤경에 빠질 수있는 전통적인 트렌드 다음 전략과 크게 대조됩니다.

위험 분석

가장 큰 위험은 RSI 지표가 때때로 잘못된 거래 신호를 줄 수 있다는 것입니다. RSI를 포함하여 시장 움직임을 예측하는 데 기술 지표는 100% 정확 할 수 없습니다. RSI가 과소 구매 / 과소 판매 상태에 대한 잘못된 판단을 할 때 전략에 대한 잘못된 항목으로 이어질 것입니다.

이러한 위험을 완화하기 위해 전략에는 스톱 손실이 구현됩니다. 그러나 강한 트렌드 동안 스톱 손실 트리거의 확률은 여전히 높을 수 있으며 잘못된 포지션을 닫기 위해 수동 개입이 필요합니다. 일반적으로 자동화 시스템이 최대 성능을 달성하려면 인간의 감독과 조정이 여전히 필요합니다.

최적화 방향

더 많은 최적화를 할 수 있습니다.

  1. 입력 신호를 확인하고 RSI에서만 잘못된 항목을 피하기 위해 다른 지표를 포함하십시오. 이동 평균 등을 추가 할 수 있습니다.

  2. RSI 매개 변수를 최적화하여 더 정확한 과잉 구매/ 과잉 판매 검출을 위해 더 나은 길이 값을 찾습니다.

  3. 손실 예방과 조기 종료를 피하는 균형을 맞추기 위해 손해를 막는 위치를 정렬합니다.

결론

전체적으로, 이 RSI 기반의 자동화 거래 전략은 과잉 구매 및 과잉 판매 시장 조건을 효과적으로 식별하는 장점이 있다. 극심한 RSI 수준에서 긴 및 짧은 포지션을 입력함으로써 시장 반전에서 이익을 얻는 것을 목표로 한다. 스톱 로스 메커니즘은 또한 강력한 일방적 트렌드 중에 손실을 제한하는 데 도움이 된다. 그러나, 잘못 판단된 RSI 신호의 위험이 남아 있다. 확인 지표, RSI 매개 변수 및 스톱 로스 배치에 대한 추가 최적화는 전략의 수익성과 위험 통제를 향상시킬 수 있다. 모든 자동화 시스템과 마찬가지로, 특별한 시장 상황에서 개입을 위해 여전히 인간의 감독이 필요하다.


/*backtest
start: 2023-02-22 00:00:00
end: 2024-02-28 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/


//@version=4

strategy("Soran Strategy 2 - LONG SIGNALS", pyramiding=1, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=50, overlay=false)


// ----------------- Inputs ----------------- //

reso = input(title="Resolution", type=input.resolution, defval="")
length = input(20, title="RSI Length", type=input.integer)
ovrsld = input(30, "RSI Oversold level", type=input.float)
ovrbgt = input(85, "RSI Overbought level", type=input.float)
lateleave = input(28, "Number of candles", type=input.integer)
// lateleave : numbers of bars in overbought/oversold zones where the position is closed. The position is closed when this number is reached or when the zone is left (the first condition).

// best parameters BTCUSDTPERP M15 : 20 / 30 / 85 / 28


stratbull = input(title="Enter longs ?", type = input.bool, defval=true)
stratbear = input(title="Enter shorts ?", type = input.bool, defval=true)

stratyear = input(2020, title = "Strategy Start Year")
stratmonth = input(1, title = "Strategy Start Month")
stratday = input(1, title = "Strategy Start Day")
stratstart = timestamp(stratyear,stratmonth,stratday,0,0)


// --------------- Laguerre ----------------- //

laguerre = input(title="Use Laguerre on RSI ?", type=input.bool, defval=false)
gamma = input(0.06, title="Laguerre Gamma")

laguerre_cal(s,g) =>
    l0 = 0.0
    l1 = 0.0
    l2 = 0.0
    l3 = 0.0
    l0 := (1 - g)*s+g*nz(l0[1])
    l1 := -g*l0+nz(l0[1])+g*nz(l1[1])
    l2 := -g*l1+nz(l1[1])+g*nz(l2[1])
    l3 := -g*l2+nz(l2[1])+g*nz(l3[1])
    (l0 + 2*l1 + 2*l2 + l3)/6


// ---------------- Rsi VWAP ---------------- //

rsiV = security(syminfo.tickerid, reso, rsi(vwap(close), length))

rsiVWAP = laguerre ? laguerre_cal(rsiV,gamma) : rsiV


// ------------------ Plots ----------------- //

prsi = plot(rsiVWAP, color = rsiVWAP>ovrbgt ? color.red : rsiVWAP<ovrsld ? color.green : color.white, title="RSI on VWAP", linewidth=1, style=plot.style_line)
hline = plot(ovrbgt, color = color.gray, style=plot.style_line)
lline = plot(ovrsld, color = color.gray, style=plot.style_line)
fill(prsi,hline, color = rsiVWAP > ovrbgt ? color.red : na, transp = 30)
fill(prsi,lline, color = rsiVWAP < ovrsld ? color.green : na, transp = 30)


// ---------------- Positions: only shows Buy and close Buy positions --------------- //

timebull = stratbull 
timebear = stratbear 

strategy.entry("Long", true, when = timebull and crossover(rsiVWAP, ovrsld), comment="")
strategy.close("Long", when = timebull and crossover(rsiVWAP, ovrbgt)[lateleave] or crossunder(rsiVWAP, ovrbgt), comment="")


더 많은