TRSI 및 SUPER 트렌드 지표에 기초한 양적 거래 전략

저자:차오장, 날짜: 2023-12-15 16:05:51
태그:

img

전반적인 설명

이 전략은 상대적 강도 지수 (TRSI) 와 슈퍼 트렌드 지표를 결합하여 비교적 완전한 양적 거래 전략을 형성합니다. 중장기 트렌드를 캡처하는 데 주로 사용되며 소음 거래 신호를 필터링하기 위해 단기 지표를 사용합니다.

전략 논리

  1. TRSI 지표를 계산하여 시장이 과소매 또는 과소매 상태에 있는지 여부를 결정하고 구매 및 판매 신호를 발행합니다.
  2. 소음 신호를 필터링 하 고 기본 트렌드를 확인 하 고 슈퍼 트렌드 표시기를 사용
  3. 수익성 있는 포지션의 다른 단계에서 스톱 로스 및 영업 포인트를 설정

특히, 전략은 먼저 시장이 과반 구매 또는 과반 판매 구역에 진입했는지 판단하기 위해 TRSI 지표를 계산하고 주요 트렌드 방향을 결정하기 위해 슈퍼 트렌드 지표를 계산합니다. 거래 신호는 둘을 결합하여 발급됩니다. 스톱 손실 및 이익 취득 포인트는 수익성의 다른 단계에서 다른 비율의 자금을 철수하도록 설정됩니다.

이점 분석

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

  1. 다중 지표 조합은 신호의 정확성을 향상시킵니다. TRSI는 타이밍을 결정하고 슈퍼 트렌드 필터는 방향입니다.
  2. 중장기 트렌드 거래에 적용됩니다. 과잉 구매 및 과잉 판매 신호는 트렌드 반전을 형성하는 경향이 있습니다.
  3. 스톱 로즈와 수익을 취하는 설정은 합리적이며, 수익성의 다른 단계에서 다른 비율의 자금을 철수하여 위험을 효과적으로 제어합니다.

위험 분석

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

  1. 중장기 거래는 단기 거래 기회를 포착하지 못합니다.
  2. 잘못된 TRSI 매개 변수 설정은 과잉 구매 및 과잉 판매 영역을 놓칠 수 있습니다.
  3. 부적절한 슈퍼 트렌드 매개 변수 설정은 잘못된 신호를 발산 할 수 있습니다.
  4. 너무 큰 스톱 로스 공간은 위험을 효과적으로 제어하지 못합니다.

이러한 위험을 해결하기 위해 우리는 다음과 같은 측면에서 최적화 할 수 있습니다.

최적화 방향

  1. 더 많은 거래 기회를 확인하기 위해 더 많은 단기 지표를 포함합니다.
  2. TRSI 매개 변수를 조정해 오류 간격을 줄여
  3. 슈퍼 트렌드 매개 변수를 테스트하고 최적화합니다.
  4. 부동 스톱 손실을 설정하여 실시간으로 스톱 손실 라인을 추적합니다.

요약

이 전략은 TRSI와 슈퍼 트렌드와 같은 여러 지표를 통합하여 비교적 완전한 양적 거래 전략을 형성합니다. 중장기 트렌드를 효과적으로 식별하면서 스톱 로스를 설정하고 리스크를 제어하기 위해 수익을 취할 수 있습니다. 여전히 최적화 할 수있는 많은 공간이 있으며, 신호 정확성을 향상시키고 더 많은 거래 기회를 식별하는 등의 분야에서 후속 개선이 가능합니다. 전반적으로 이것은 양적 전략의 좋은 출발점입니다.


/*backtest
start: 2022-12-14 00:00:00
end: 2023-11-26 05:20:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/


//@version=4
strategy(title = "SuperTREX strategy", overlay = true)
strat_dir_input = input(title="Strategy Direction", defval="long", options=["long", "short", "all"])
strat_dir_value = strat_dir_input == "long" ? strategy.direction.long : strat_dir_input == "short" ? strategy.direction.short : strategy.direction.all
strategy.risk.allow_entry_in(strat_dir_value)
length = input( 14 )
overSold = input( 35 )
overBought = input( 70 )
HTF = input("W", type=input.resolution)
ti = change( time(HTF) ) != 0
p = fixnan( ti ? close : na )

vrsi = rsi(p, length)
price = close
var bool long = na
var bool short = na

long :=crossover(vrsi,overSold) 
short := crossunder(vrsi,overBought)

var float last_open_long = na
var float last_open_short = na

last_open_long := long ? close : nz(last_open_long[1])
last_open_short := short ? close : nz(last_open_short[1])


entry_value =last_open_long
entry_value1=last_open_short

xy=(entry_value+entry_value)/2

// INPUTS //
st_mult   = input(4,   title = 'SuperTrend Multiplier', minval = 0, maxval = 100, step = 0.01)
st_period = input(10, title = 'SuperTrend Period',     minval = 1)

// CALCULATIONS //
up_lev =xy - (st_mult * atr(st_period))
dn_lev =xy + (st_mult * atr(st_period))

up_trend   = 0.0
up_trend   := entry_value[1] > up_trend[1]   ? max(up_lev, up_trend[1])   : up_lev

down_trend = 0.0
down_trend := entry_value1[1] < down_trend[1] ? min(dn_lev, down_trend[1]) : dn_lev

// Calculate trend var
trend = 0
trend := close > down_trend[1] ? 1: close < up_trend[1] ? -1 : nz(trend[1], 1)

// Calculate SuperTrend Line
st_line = trend ==1 ? up_trend : down_trend
plot(xy,color = trend == 1 ? color.green : color.red)

buy=crossover( close, st_line) 
sell1=crossunder(close, st_line) 
 


buy1=buy
//

sell=sell1


// STRATEGY

plotshape(buy , title="buy", text="Buy", color=color.green, style=shape.labelup, location=location.belowbar, size=size.small, textcolor=color.white, transp=0)  //plot for buy icon
plotshape(sell, title="sell", text="Sell", color=color.red, style=shape.labeldown, location=location.abovebar, size=size.small, textcolor=color.white, transp=0)  //plot for sell icon
// Take profit

//
l = buy 
s1=sell 
if l 
    strategy.entry("buy", strategy.long)
if s1 
    strategy.entry("sell", strategy.short)
per(pcnt) =>  strategy.position_size != 0 ? round(pcnt / 100 * strategy.position_avg_price / syminfo.mintick) : float(na)
stoploss=input(title=" stop loss", defval=25, minval=0.01)
los = per(stoploss)
q1=input(title=" qty_percent1", defval=25, minval=1)
q2=input(title=" qty_percent2", defval=25, minval=1)
q3=input(title=" qty_percent3", defval=25, minval=1)
tp1=input(title=" Take profit1", defval=2, minval=0.01)
tp2=input(title=" Take profit2", defval=4, minval=0.01)
tp3=input(title=" Take profit3", defval=6, minval=0.01)
tp4=input(title=" Take profit4", defval=8, minval=0.01)
strategy.exit("x1", qty_percent = q1, profit = per(tp1), loss = los)
strategy.exit("x2", qty_percent = q2, profit = per(tp2), loss = los)
strategy.exit("x3", qty_percent = q3, profit = per(tp3), loss = los)
strategy.exit("x4", profit = per(tp4), loss = los)


더 많은