빠른 RSI 반전 거래 전략


생성 날짜: 2024-03-01 11:55:56 마지막으로 수정됨: 2024-03-01 11:55:56
복사: 2 클릭수: 617
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

빠른 RSI 반전 거래 전략

개요

빠른 RSI 역전 거래 전략은 빠른 RSI 지표, K선 엔티티 필터, 최대 최소 가격 필터 및 SMA 평균 라인 필터를 조합하여 트렌드 역전 지점을 판단하여 낮은 위험의 역전 거래를 실현합니다. 이 전략은 단기 반전 기회를 잡기 위해 고안되었습니다.

전략 원칙

이 전략은 다음과 같은 몇 가지 지표에 따라 판단됩니다.

  1. 빠른 RSI 지표: RSI를 RMA 함수를 통해 계산하여 더 민감하게 OTC 신호를 더 빨리 잡을 수 있습니다.

  2. K선 엔티티 필터: K선 엔티티의 크기가 EMA 엔티티 평균선의 15, 필터 변동이 크지 않은 경우를 요구한다.

  3. 최대 최소 가격 필터“가격 혁신이 높거나 낮다고 판단하고, 트렌드가 바뀌었다는 것을 확인한다”.

  4. SMA 평선 필터: 가격이 SMA 평균선을 뚫고 판단기반을 늘리도록 요구한다.

위와 같은 여러 조건이 동시에 발생하면 거래 신호가 발생한다. 구체적인 논리는 다음과 같다:

다단 입시: 빠른 RSI 지표가 초매 지역보다 낮고 AND K 선 엔티티가 EMA 엔티티 평균선보다 크며 15 AND가 최소값을 뚫고 AND가 SMA 평균선을 통과합니다.

공허 입시: 빠른 RSI 지표가 초매 지역보다 높으며 AND K 선 엔티티가 EMA 엔티티 평균선보다 크며 15 AND가 최대 값을 뚫고 AND 가격이 SMA 평균선 아래로 통과합니다.

평지 탈퇴: 급격한 RSI가 정상 영역으로 돌아왔다.

전략적 이점

이 전략은 다음과 같은 장점을 가지고 있습니다.

  1. 단기적 역동성을 포착하는 방법
  2. 빠른 RSI 지표의 민감도가 높습니다.
  3. 복합 필터링으로 가짜 신호를 줄일 수 있다.
  4. 위험은 통제할 수 있고, 철회도 적습니다.

위험과 최적화

이 전략에는 몇 가지 위험도 있습니다.

  1. 역전 실패의 위험
  2. 매개 변수 최적화 공간 제한

다음의 방법으로 더 최적화할 수 있습니다:

  1. 거래량 필터링
  2. 더 많은 손실을 막는 전략
  3. 최적화 변수 모음

요약하다

이 전략은 전반적으로 낮은 위험의 단기 역전 거래 전략이다. 그것은 빠른 RSI 지표를 통해 매도점을 판단하고, 여러 필터를 사용하여 가짜 신호를 줄여서, 위험을 제어할 수 있는 역전 거래를 실현하고, 짧은 라인 운영에 적합하다. 이 전략은 더 나아가 최적화될 수 있으며, 큰 발전 잠재력을 가지고 있다.

전략 소스 코드
/*backtest
start: 2024-02-01 00:00:00
end: 2024-02-26 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//Noro
//2018

//@version=3
strategy(title = "Noro's Fast RSI Strategy v1.4", shorttitle = "Fast RSI str 1.4", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 5)

//Settings
needlong = input(true, defval = true, title = "Long")
needshort = input(true, defval = true, title = "Short")
usersi = input(true, defval = true, title = "Use Fast RSI Strategy")
usemm = input(true, defval = true, title = "Use Min/Max Strategy")
usesma = input(true, defval = true, title = "Use SMA Filter")
smaperiod = input(20, defval = 20, minval = 2, maxval = 1000, title = "SMA Filter Period")
rsiperiod = input(7, defval = 7, minval = 2, maxval = 50, title = "RSI Period")
limit = input(30, defval = 30, minval = 1, maxval = 100, title = "RSI limit")
rsisrc = input(close, defval = close, title = "RSI Price")
rsibars = input(1, defval = 1, minval = 1, maxval = 20, title = "RSI Bars")
mmbars = input(1, defval = 1, minval = 1, maxval = 5, title = "Min/Max Bars")
showsma = input(false, defval = false, title = "Show SMA Filter")
showarr = input(false, defval = false, title = "Show Arrows")
fromyear = input(2018, defval = 2018, minval = 1900, maxval = 2100, title = "From Year")
toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")
frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")
tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month")
fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From day")
today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")

//Fast RSI
fastup = rma(max(change(rsisrc), 0), rsiperiod)
fastdown = rma(-min(change(rsisrc), 0), rsiperiod)
fastrsi = fastdown == 0 ? 100 : fastup == 0 ? 0 : 100 - (100 / (1 + fastup / fastdown))

//Limits
bar = close > open ? 1 : close < open ? -1 : 0
uplimit = 100 - limit
dnlimit = limit

//RSI Bars
upsignal = fastrsi > uplimit ? 1 : 0
dnsignal = fastrsi < dnlimit ? 1 : 0
uprsi = sma(upsignal, rsibars) == 1
dnrsi = sma(dnsignal, rsibars) == 1

//Body
body = abs(close - open)
emabody = ema(body, 30)

//MinMax Bars
min = min(close, open)
max = max(close, open)
minsignal = min < min[1] and bar == -1 and bar[1] == -1 ? 1 : 0
maxsignal = max > max[1] and bar == 1 and bar[1] == 1 ? 1 : 0
mins = sma(minsignal, mmbars) == 1
maxs = sma(maxsignal, mmbars) == 1

//SMA Filter
sma = sma(close, smaperiod)
colorsma = showsma ? blue : na
plot(sma, color = colorsma, linewidth = 3)

//Signals
up1 = bar == -1 and (strategy.position_size == 0 or close < strategy.position_avg_price) and dnrsi and body > emabody / 5 and usersi
dn1 = bar == 1 and (strategy.position_size == 0 or close > strategy.position_avg_price) and uprsi and body > emabody / 5 and usersi
up2 = mins and (close > sma or usesma == false) and usemm
dn2 = maxs and (close < sma or usesma == false) and usemm 
exit = ((strategy.position_size > 0 and fastrsi > dnlimit and bar == 1) or (strategy.position_size < 0 and fastrsi < uplimit and bar == -1)) and body > emabody / 2

//Arrows
col = exit ? black : up1 or dn1 ? blue : up2 or dn2 ? red : na
needup = up1 or up2
needdn = dn1 or dn2
needexitup = exit and strategy.position_size < 0
needexitdn = exit and strategy.position_size > 0
plotarrow(showarr and needup ? 1 : na, colorup = blue, colordown = blue, transp = 0)
plotarrow(showarr and needdn ? -1 : na, colorup = blue, colordown = blue, transp = 0)
plotarrow(showarr and needexitup ? 1 : na, colorup = black, colordown = black, transp = 0)
plotarrow(showarr and needexitdn ? -1 : na, colorup = black, colordown = black, transp = 0)

//Trading
if up1 or up2
    strategy.entry("Long", strategy.long, needlong == false ? 0 : na)

if dn1 or dn2
    strategy.entry("Short", strategy.short, needshort == false ? 0 : na)
    
if time > timestamp(toyear, tomonth, today, 00, 00) or exit
    strategy.close_all()