빠른 RSI 브레이크 트레이딩 전략

저자:차오장, 날짜: 2023-09-12 16:34:21
태그:

이 전략은 빠른 RSI 지표를 사용하여 RSI 극한을 거래하고 윙사 (whipsaws) 를 피하기 위해 촛불 몸의 크기에 따라 항목을 필터합니다. 급속히 반전을 포착하기 위해 과반 구매 / 과반 판매 수준을 신속하게 식별하는 것을 목표로합니다.

전략 논리:

  1. 빠른 RSI를 계산하고 과잉 구매/ 과잉 판매 임계치를 설정합니다.

  2. 몸집 필터링을 위해 촛불 몸집 크기의 EMA를 계산합니다.

  3. RSI가 오버구입 라인을 넘어서고 EMA의 절반을 넘어서면 롱으로 이동합니다.

  4. RSI가 원래의 임계치 아래로 다시 넘어가면 EMA를 넘어서게 됩니다.

  5. 미니/맥스는 추가 신호 검증을 제공할 수 있습니다.

장점:

  1. 빠른 RSI는 신호 생성 속도를 높이고 지연을 피합니다.

  2. 몸 크기의 필터는 촛불의 소음을 줄여줍니다.

  3. 최소/최대 신호 품질을 향상시킵니다.

위험성:

  1. 신체 필터링은 유효한 신호를 놓칠 수도 있습니다.

  2. 시장에서 RSI에 대한 Whipsaws는 여전히 가능합니다.

  3. 리버설 거래에 필요한 엄격한 리스크 관리

요약하자면, 이 전략은 빠른 RSI와 체형 필터링을 결합하여 더 빠르고 안정적인 과잉 구매/ 과잉 판매 검출을 수행합니다. 그러나 과잉 필터링 문제는 여전히 남아 있으므로 신중한 위험 통제가 여전히 필요합니다.


/*backtest
start: 2023-01-01 00:00:00
end: 2023-09-11 00:00:00
period: 2d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
strategy(title = "Noro's Fast RSI Strategy v1.3", shorttitle = "Fast RSI str 1.3", 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")
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")
rb = input(1, defval = 1, minval = 1, maxval = 5, title = "RSI Bars")
usemm = input(false, defval = false, title = "Use Min/Max")
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
ur = fastrsi > uplimit
dr = fastrsi < dnlimit
uprsi = rb == 1 and ur ? 1 : rb == 2 and ur and ur[1] ? 1 : rb == 3 and ur and ur[1] and ur[2] ? 1 : rb == 4 and ur and ur[1] and ur[2] and ur[3] ? 1 : rb == 5 and ur and ur[1] and ur[2] and ur[3] and ur[4] ? 1 : 0
dnrsi = rb == 1 and dr ? 1 : rb == 2 and dr and dr[1] ? 1 : rb == 3 and dr and dr[1] and dr[2] ? 1 : rb == 4 and dr and dr[1] and dr[2] and dr[3] ? 1 : rb == 5 and dr and dr[1] and dr[2] and dr[3] and dr[4] ? 1 : 0

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

//MinMax
min = min(close, open)
max = max(close, open)

//Signals
up1 = bar == -1 and (strategy.position_size == 0 or close < strategy.position_avg_price) and dnrsi and body > emabody / 4
dn1 = bar == 1 and (strategy.position_size == 0 or close > strategy.position_avg_price) and uprsi and body > emabody / 4
up2 = min < min[1] and bar == -1 and bar[1] == -1 and usemm
dn2 = max > max[1] and bar == 1 and bar[1] == 1 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 and usemm)
needdn = dn1 or (dn2 and usemm)
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, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 00, 00)))

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

더 많은