급속한 RSI 리스크 제어 복합 선물 거래 전략

저자:차오장, 날짜: 2023-11-13 11:36:34
태그:

img

전반적인 설명

이 전략은 스팟 거래 플랫폼 BitMEX를 위해 설계되었습니다. 빠른 RSI 지표를 분석하고 여러 기술적 지표를 스크린 신호로 결합하여 효율적인 트렌드 추적 거래를 실현합니다. 이 전략은 또한 거래 위험을 효과적으로 제어하기 위해 위험 관리 및 스톱 손실 메커니즘을 설정합니다.

전략 논리

  1. 7 일과 과잉 구매 라인 25, 과잉 판매 라인 75의 매개 변수와 함께 빠른 RSI를 계산하십시오. RSI가 과잉 구매 라인을 넘을 때, 그것은 과잉 구매 신호입니다. RSI가 과잉 판매 라인을 넘을 때, 그것은 과잉 판매 신호입니다.

  2. 촛불체에 필터를 설정합니다. 몸의 길이가 어제 평균 몸의 길이의 20% 미만으로 하향 촛불로 열어야합니다.

  3. 촛불의 색에 필터를 설정합니다. 짧은 경우 마지막 4 개의 촛불이 하락하고, 긴 경우 마지막 4 개의 촛불이 상승합니다.

  4. 스톱 로스 로직을 설정합니다. 가격이 불리한 방향으로 움직일 때 포지션을 닫습니다.

  5. 안티 윙사 메커니즘을 설정합니다. 첫 번째 움직임 이후 손실 수준을 중지하기 위해 가격이 회복되면 신호를 취합니다.

  6. 포지션 크기를 설정하세요. 각 거래에 대해 자본의 일정한 비율을 사용하세요. 그리고 각 손실 후에 포지션 크기를 두 배로 늘려주세요.

이점 분석

  1. 합리적으로 설정 된 빠른 RSI 매개 변수는 트렌드를 신속하게 파악 할 수 있습니다. 촛불체와 색상 필터와 결합하면 잘못된 파장을 효과적으로 피할 수 있습니다.

  2. 다층 필터는 트레이드 수를 줄임으로써 승률을 높입니다.

  3. 내장된 스톱 로스 메커니즘으로 거래당 손실 제한

  4. 역동적인 포지션 사이징은 적당히 공격적인 자본 관리를 실현합니다.

  5. 커스터마이징 가능한 거래 시간 프레임은 주요 이벤트의 소음을 피합니다.

위험 과 최적화

  1. 고속은 거래 기회를 놓칠 수 있습니다. 더 많은 유연성을 위해 매개 변수를 느슨하게 할 수 있습니다.

  2. 트렌드 종결을 결정하기 어렵기 때문에 다른 지표와 결합하여 잠재적인 반전을 감지하는 것을 고려하십시오.

  3. 위치 크기를 측정하는 방법은 너무 공격적이어서 위치 로킹 방법을 도입할 수 있습니다.

  4. 다른 시장에 대한 매개 변수를 최적화하여 더 나은 매개 변수 조합을 찾을 수 있습니다.

결론

전체적으로 이 전략은 상당히 견고하다. 빠른 RSI로 트렌드 방향을 판단하고 여러 지표로 신호를 필터링함으로써 트렌드 중에 좋은 수익을 얻을 수 있다. 또한 전략은 최적화 할 여지가 있다. 매개 변수 조합을 조정함으로써 다른 시장 환경에 적응할 수 있어 실용성이 좋다.


/*backtest
start: 2023-11-05 00:00:00
end: 2023-11-12 00:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//Noro
//2018

//@version=2
strategy(title = "Robot BitMEX Fast RSI v1.0", shorttitle = "Robot BitMEX Fast RSI v1.0", overlay = false, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 10)

//Settings
needlong = input(true, defval = true, title = "Long")
needshort = input(true, defval = true, title = "Short")
usemar = input(true, defval = true, title = "Use Martingale")
capital = input(100, defval = 100, minval = 1, maxval = 10000, title = "Capital, %")
rsiperiod = input(7, defval = 7, minval = 2, maxval = 100, title = "RSI Period")
rsilimit = input(25, defval = 25, minval = 1, maxval = 30, title = "RSI limit")
rsibars = input(1, defval = 1, minval = 1, maxval = 20, title = "RSI Bars")
useocf = input(true, defval = true, title = "Use Open Color Filter")
useccf = input(true, defval = true, title = "Use Close Color Filter")
openbars = input(4, defval = 4, minval = 1, maxval = 20, title = "Open Color Bars")
closebars = input(1, defval = 1, minval = 1, maxval = 20, title = "Close Color Bars")
useobf = input(true, defval = true, title = "Use Open Body Filter")
usecbf = input(true, defval = true, title = "Use Close Body Filter")
openbody = input(20, defval = 20, minval = 0, maxval = 1000, title = "Open Body Minimum, %")
closebody = input(50, defval = 50, minval = 0, maxval = 1000, title = "Close Body Minimum, %")
usecnf = input(true, defval = true, title = "Use Close Norma Filter")
fromyear = input(1900, defval = 1900, 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")

//RSI
uprsi = rma(max(change(close), 0), rsiperiod)
dnrsi = rma(-min(change(close), 0), rsiperiod)
rsi = dnrsi == 0 ? 100 : uprsi == 0 ? 0 : 100 - (100 / (1 + uprsi / dnrsi))
uplimit = 100 - rsilimit
dnlimit = rsilimit
rsidn = rsi < dnlimit ? 1 : 0
rsiup = rsi > uplimit ? 1 : 0
rsidnok = sma(rsidn, rsibars) == 1
rsiupok = sma(rsiup, rsibars) == 1

//Body Filter
body = abs(close - open)
abody = sma(body, 10)
openbodyok = body >= abody / 100 * openbody or useobf == false
closebodyok = body >= abody / 100 * closebody or usecbf == false

//Color Filter
bar = close > open ? 1 : close < open ? -1 : 0
gbar = bar == 1 ? 1 : 0
rbar = bar == -1 ? 1 : 0
opengbarok = sma(gbar, openbars) == 1 or useocf == false
openrbarok = sma(rbar, openbars) == 1 or useocf == false
closebarok = (strategy.position_size > 0 and bar == 1) or (strategy.position_size < 0 and bar == -1) or useccf == false

//Norma Filter
norma = (rsi > dnlimit and rsi < uplimit) or usecnf == false

//Signals
up = openrbarok and rsidnok and openbodyok and (strategy.position_size == 0 or close < strategy.position_avg_price)
dn = opengbarok and rsiupok and openbodyok and (strategy.position_size == 0 or close > strategy.position_avg_price)
exit = ((strategy.position_size > 0 and closebarok and norma) or (strategy.position_size < 0 and closebarok and norma)) and closebodyok

//Indicator
plot(rsi, color = blue, linewidth = 3, title = "Double RSI")
plot(uplimit, color = black, title = "Upper Line")
plot(dnlimit, color = black, title = "Lower Line")
colbg = rsi > uplimit ? red : rsi < dnlimit ? lime : na
bgcolor(colbg, transp = 20)

//Trading
profit = exit ? ((strategy.position_size > 0 and close > strategy.position_avg_price) or (strategy.position_size < 0 and close < strategy.position_avg_price)) ? 1 : -1 : profit[1]
mult = usemar ? exit ? profit == -1 ? mult[1] * 2 : 1 : mult[1] : 1
lot = strategy.position_size == 0 ? strategy.equity / close * capital / 100 * mult : lot[1]

if up
    if strategy.position_size < 0
        strategy.close_all()
        
    strategy.entry("Long", strategy.long, needlong == false ? 0 : lot, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))

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

더 많은