RSI 지표 신호에 기초한 양적 거래 전략

저자:차오장, 날짜: 2023-09-14 20:26:49
태그:

이 문서에서는 거래 신호를 생성하기 위해 RSI 지표를 사용하는 양적 거래 전략을 자세히 설명합니다. RSI 지표를 처리하고 긴 거래와 짧은 거래에 대한 입출 기준을 설정합니다.

I. 전략 논리

주요 거래 논리는 다음과 같습니다.

  1. RSI ((14) 인디케이터를 계산하고 EMA ((28) 를 사용하여 가공된 오시일레이터를 얻기 위해 평평화합니다.

  2. 처리된 RSI에서 볼링거 밴드를 계산하여 상위/하위 밴드를 얻습니다. 과잉 구매/ 과잉 판매 구역을 설정합니다.

  3. 처리된 RSI가 엔트리 라인의 아래를 넘으면 구매 신호가 생성됩니다.

  4. 지표가 과잉 구매/ 과잉 판매 구역에 들어갈 때, 마감 포지션 신호가 생성됩니다.

이러한 방식으로, RSI의 특성은 반전 기회를 포착하는 데 사용될 수 있습니다. 지표 처리 또한 신호 품질 및 참조 값을 향상시킵니다.

II. 전략의 장점

가장 큰 장점은 지표 처리로 인해 매개 변수 조정 공간이 증가하여 거래 빈도에 대한 더 엄격한 통제를 허용하고 과도한 거래를 방지하는 것입니다.

또 다른 장점은 지표의 명확한 수치 값에 기초한 직관적인 입시 기준입니다.

마지막으로, 과잉 구매/ 과잉 판매 범위는 또한 거래 당 적시에 수익을 창출하고 위험을 통제하는 데 도움이됩니다.

III. 잠재적인 약점

그러나 이 전략은 다음과 같은 위험을 가지고 있습니다.

첫째, RSI는 트렌드 도중 잘못된 신호를 생성할 수 있는 반전 트레이드에 초점을 맞추고 있습니다.

둘째, 부적절한 매개 변수 조정도 과도한 최적화와 변화하는 시장 조건에 적응하지 못하는 결과를 초래할 수 있습니다.

마지막으로, 상대적으로 낮은 승률은 또한 전략을 끌어내기 위험에 노출시킵니다.

IV. 요약

요약적으로,이 기사는 주로 RSI 지표를 활용한 양적 거래 전략을 소개합니다. 매개 변수 조정을 통해 거래 주파수를 제어하고 명확한 입출입 규칙을 가지고 있습니다. 매개 변수를 최적화하는 동안 역전 거래의 위험도 관리해야합니다. 전반적으로 간단하고 직관적인 RSI 전략 프레임워크를 제공합니다.


/*backtest
start: 2023-08-14 00:00:00
end: 2023-09-13 00:00:00
period: 3h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
//-----------------------------------------------------------------
//This simple strategy base on RSI, EMA, Bollinger Bands to get Buy and Sell Signal with detail as below:
//-----------------------------------------------------------------
//1.Define Oscillator Line
//+ Oscillator Line is smoothed by ema(28) of RSI(14) on H1 Timeframe
//2.Define Overbought and Oversold
//+ Apply Bollinger Bands BB(80,3) on Oscillator Line and calculate %b
//+ Overbought Zone marked above level 0.8
//+ Oversold Zone marked below level 0.2
//3.Buy Signal
//+ Entry Long Positon when %b crossover Point of Entry Long
//+ Deafault Point of Entry Long is 0.2
//+ Buy signal marked by Green dot
//4.Sell Signal
//+ Entry Short Position when %b crossunder Point of Entry Short
//+ Deafault Point of Entry Short is 0.8
//+ Sell signal marked by Red dot
//5.Exit Signal
//+ Exit Position (both Long and Short) when %b go into Overbought Zone or Oversold Zone
//+ Exit signal marked by Yellow dot
//-----------------------------------------------------------------
strategy(title="RSI %b Signal [H1 Backtesting]", overlay=false)

//RSI
rsi_gr="=== RSI ==="
rsi_len = input(14, title = "RSI",inline="set",group=rsi_gr)
smoothed_len = input(28, title = "EMA",inline="set",group=rsi_gr)
rsi=ta.ema(ta.rsi(close,rsi_len),smoothed_len)
//rsi's BOLLINGER BANDS
pb_gr="=== %b ==="
length = input(80, title = "Length",inline="set1",group=pb_gr)
rsimult = input(3.0, title = "Multiplier",inline="set1",group=pb_gr)
ovb = input(0.8, title = "Overbought",inline="set2",group=pb_gr)
ovs = input(0.2, title = "Oversold",inline="set2",group=pb_gr)
et_short = input(0.8, title = "Entry Short",inline="set3",group=pb_gr)
et_long = input(0.2, title = "Entry Long",inline="set3",group=pb_gr)
[rsibasis, rsiupper, rsilower] = ta.bb(rsi, length, rsimult)
//rsi's %B
rsipB = ((rsi - rsilower) / (rsiupper - rsilower))
plot(rsipB, title="rsi's %B", color=rsipB>math.min(ovb,et_short)?color.red:rsipB<math.max(ovs,et_long)?color.green:color.aqua, linewidth=1)

h1=hline(1,color=color.new(color.red,100))
h4=hline(ovb,color=color.new(color.red,100))
h0=hline(0,color=color.new(color.green,100))
h3=hline(ovs,color=color.new(color.green,100))
h5=hline(0.5,color=color.new(color.silver,0),linestyle=hline.style_dotted)

fill(h1,h4, title="Resistance", color=color.new(color.red,90))
fill(h0,h3, title="Support", color=color.new(color.green,90))

//Signal
rsi_buy=
           rsipB[1]<et_long
           and
           rsipB>et_long
rsi_sell=
           rsipB[1]>et_short
           and
           rsipB<et_short
rsi_exit=
           (rsipB[1]>ovs and rsipB<ovs)
           or
           (rsipB[1]<ovb and rsipB>ovb)
plotshape(rsi_buy?rsipB:na,title="Buy",style=shape.circle,color=color.new(color.green,0),location=location.absolute)
plotshape(rsi_sell?rsipB:na,title="Sell",style=shape.circle,color=color.new(color.red,0),location=location.absolute)
plotshape(rsi_exit?rsipB:na,title="Exit",style=shape.circle,color=color.new(color.yellow,0),location=location.absolute)
//Alert
strategy.entry("Long",strategy.long,when=rsi_buy)
strategy.close("Long",when=rsi_exit)
strategy.entry("Short",strategy.short,when=rsi_sell)
strategy.close("Short",when=rsi_exit)
//EOF

더 많은