RSI 기반의 상승 추세 전략

저자:차오장, 날짜: 2023-12-25 14:32:19
태그:

img

전반적인 설명

이 전략은 상대 강도 지수 (RSI) 인디케이터를 기반으로 RSI의 낮은 지점에서 구매하고 RSI의 높은 지점에서 수익 및 스톱 손실을 취하기 위해 설계되었습니다. RSI가 과판 라인의 아래에 떨어지면 구매 신호를 생성하고 RSI가 과판 라인의 위에 상승하면 판매 신호를 생성합니다. 전략은 효과적인 위험 통제로 트렌드를 추적하도록 최적화되었습니다.

전략 논리

이 전략은 주가가 과대평가되거나 과대평가되었는지 여부를 결정하기 위해 RSI 지표를 사용합니다. RSI는 과소득 및 과소득 라인과 결합하여 구매 및 판매 신호를 형성합니다. 구체적으로, RSI가 20 과소득 라인을 넘으면 구매 신호가 생성됩니다. RSI가 80 과소득 라인을 넘으면 판매 신호가 생성됩니다.

긴 포지션에 진입한 후, 전략은 하향 위험을 제어하기 위해 초기 스톱 로스를 설정합니다. 동시에, 다른 비율을 가진 두 가지 수익 라인이 팩으로 수익을 취하고 수익을 잠금하도록 설정됩니다. 구체적으로, 포지션의 50%는 입시 가격보다 3% 높게 수익을 취합니다. 그 다음 나머지 50% 포지션은 입시 가격보다 5% 높게 수익을 취합니다.

이 전략은 RSI 지표를 효과적으로 활용하여 진입 시기를 결정합니다. 스톱 로스 및 영업 설정은 위험을 효과적으로 제어하기 위해 합리적입니다.

장점

  • RSI 지표를 사용하여 긴/단기 포지션을 결정하고 맹목적으로 거래를 피하십시오.
  • 더 나은 지표 효과를 위해 최적화된 RSI 매개 변수
  • 합리적인 이중 이익 취득 설계는 더 많은 이익을 확보하기 위해 대량으로 이익을 취득 할 수 있습니다.
  • 초기 스톱 손실과 후속 스톱 손실은 엄청난 손실을 방지합니다.

위험성

  • 이윤을 유지할 수 없는 황금시장에서의 부진한 성과
  • RSI로부터 잘못된 신호가 나올 확률이 존재하고 잘못된 신호 판단으로 인한 손실을 증가시킬 수 있습니다.
  • 스톱 로스 포인트가 너무 높게 설정되면 스톱을 유발할 수 없는 위험
  • 피라미드 시간 및 비율에 대한 제한 없이 증가 손실 위험

개선

  • 다른 지표를 추가하여 RSI 신호를 필터링하고 정확도를 향상시킵니다.
  • 피라미드 시간 및 비율에 제한을 설정
  • 다른 RSI 매개 변수의 테스트 효과
  • 스톱 로스를 최적화하고 리스크를 낮추기 위해 수익 포인트를 취합니다.

요약

이 전략은 시장 상태를 판단하기 위해 RSI를 활용하고 합리적인 스톱 로스 및 이익 취득 구성을 가지고 있습니다. 시장 트렌드를 효과적으로 결정하고 거래 위험을 제어 할 수 있으며, 전략에 따른 상승 트렌드로 적합합니다. 신호 필터링, 매개 변수 테스트, 스톱 로스 최적화 등이 전략의 안정성을 더욱 향상시킬 수 있습니다.


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

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/

//@version=5

strategy(title='RSI Long Strategy', overlay=true, pyramiding=5, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, calc_on_order_fills=false, slippage=0, commission_type=strategy.commission.percent, commission_value=0.075)
strat_dir_input = input.string(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)
//INPUTS


length = input(21)
overSold = input(20)
overBought = input(80)
p = close

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

long := ta.crossover(vrsi, overSold)
short := ta.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])
mpoint=(last_open_long+last_open_short)/2

entry_value = last_open_long
entry_value1 = last_open_short

// Rounding levels to min tick
nround(x) =>
    n = math.round(x / syminfo.mintick) * syminfo.mintick
    n
//
disp_panels = input(true, title='Display info panels?')
fibs_label_off = input(40, title='fibs label offset')
fibs_label_size = input.string(size.normal, options=[size.tiny, size.small, size.normal, size.large, size.huge], title='fibs label size')
r1_x = timenow + math.round(ta.change(time) * fibs_label_off)
r1_y = last_open_short
text1 = 'High : ' + str.tostring(nround(last_open_short))
s1_y = last_open_long
text3 = 'low : ' + str.tostring(nround(last_open_long))

R1_label = disp_panels ? label.new(x=r1_x, y=r1_y, text=text1, xloc=xloc.bar_time, yloc=yloc.price, color=color.orange, style=label.style_label_down, textcolor=color.black, size=fibs_label_size) : na
S1_label = disp_panels ? label.new(x=r1_x, y=s1_y, text=text3, xloc=xloc.bar_time, yloc=yloc.price, color=color.lime, style=label.style_label_up, textcolor=color.black, size=fibs_label_size) : na

label.delete(R1_label[1])
label.delete(S1_label[1])
//
plot(mpoint, title='avreage', color=color.new(color.red, 40), style=plot.style_linebr, linewidth=3, trackprice=true, offset=-9999)
plot(last_open_short, title='high', color=color.new(color.red, 40), style=plot.style_linebr, linewidth=3, trackprice=true, offset=-9999)
plot(last_open_long, title='low', color=color.new(color.blue, 40), style=plot.style_linebr, linewidth=3, trackprice=true, offset=-9999)
//
trend = input(false)
if barstate.islast and trend == true
    line z = line.new(bar_index[1], last_open_short[1], bar_index, last_open_short, extend=extend.both, color=color.red, style=line.style_dashed, width=1)
    line f = line.new(bar_index[1], mpoint[1], bar_index, mpoint, extend=extend.both, color=color.blue, style=line.style_dashed, width=1)
    line w = line.new(bar_index[1], last_open_long[1], bar_index, last_open_long, extend=extend.both, color=color.green, style=line.style_dashed, width=1)
    line.delete(z[1])
    line.delete(f[1])
    line.delete(w[1])
    
//bu = ta.crossover(close, mpoint)
//sz = ta.crossunder(close, mpoint)
//bu1 = ta.crossover(close, last_open_short)
sz1 = ta.crossunder(close, last_open_short)
bu2 = ta.crossover(close, last_open_long)
//sz2 = ta.crossunder(close, last_open_long)
//plotshape(sz, style=shape.triangledown, location=location.abovebar, color=color.new(color.orange, 0), size=size.tiny)
//plotshape(bu, style=shape.triangleup, location=location.belowbar, color=color.new(color.blue, 0), size=size.tiny)
//plotshape(sz1, style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), size=size.tiny)
//plotshape(bu1, style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), size=size.tiny)
//plotshape(sz2, style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), size=size.tiny)
//plotshape(bu2, style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), size=size.tiny)

l = bu2
s = sz1 
if l
    strategy.entry('buy', strategy.long)
if s
    strategy.entry('sell', strategy.short)
per(pcnt) =>
    strategy.position_size != 0 ? math.round(pcnt / 100 * strategy.position_avg_price / syminfo.mintick) : float(na)
stoploss = input.float(title=' stop loss', defval=5, minval=0.01)
los = per(stoploss)
q1 = input.int(title=' qty_percent1', defval=50, minval=1)
q2 = input.int(title=' qty_percent2', defval=50, minval=1)
tp1 = input.float(title=' Take profit1', defval=3, minval=0.01)
tp2 = input.float(title=' Take profit2', defval=5, minval=0.01)
//tp4 = input.float(title=' Take profit4', defval=5, 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)



더 많은