RSI インディケーター 信号 に 基づく 定量 的 取引 戦略

作者: リン・ハーンチャオチャン, 日時: 2023-09-14 20:26:49
タグ:

この記事では,RSIインジケータを利用して取引信号を生成する定量的な取引戦略を詳細に説明します. RSIインジケータを処理し,ロングとショート取引のエントリーと出口基準を設定します.

I. 戦略の論理

主な取引論理は以下のとおりです

  1. 処理されたオシレーターを得るために,RSI (※14) インディケーターを計算し,EMA (※28) を使ってそれを平滑化します.

  2. 処理されたRSIでボリンジャー帯を計算して上/下帯を得ます. 過買い/過売りゾーンを設定します.

  3. 処理されたRSIがエントリーラインを下回ると,買い信号が生成されます. 上回ると,売り信号が生成されます.

  4. この指標が過買い/過売りゾーンに入ると,閉店シグナルが生成されます.

RSIの特徴は逆転の機会を把握するために利用できる.指標処理は信号品質と基準値を向上させる.

戦略の利点

最大の利点は,指標処理によるパラメータ調整スペースの拡大であり,取引頻度をより厳しく制御し,過剰取引を防ぐことができます.

もう一つの利点は,指標の明確な数値に基づいた直感的なエントリー基準です.

最後に,過剰購入/過剰売却の範囲は,取引ごとに適時利益とリスク管理にも役立ちます.

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

もっと