RSI ダイバージェンツ・トレーディング戦略

作者: リン・ハーンチャオチャン, 日付: 2023年10月25日 16時47分14秒
タグ:

img

概要

RSIダイバージェンツ・トレーディング戦略は,RSI指標と価格動きの間の差異を特定することによって,買い・売るシグナルを生成する.また,戦略には,リスクを効果的に管理するためにストップ・ロース,テイク・プロフィート,トラッキング・ストップ・ロースも組み込まれています.

原則

この戦略は,主にRSI指標の差異を使用して取引機会を特定する.具体的には,戦略は最初に特定の期間中のRSI値を計算し,その後,RSI指標と価格の両方のトレンドラインをプロットする.RSIラインが価格ラインから逸脱したとき,すなわちRSIが価格が下がっている間に上昇するか,RSIが価格が上昇している間に下がると,戦略はそれを差し迫ったトレンド逆転の兆候として捉え,取引信号を生成する.

ストラテジーは,価格ラインが上位に立つ間,RSIラインが底部に達することを検出すると,購入信号が生成されます.価格ラインが下位に立つ間,RSIラインが上位に立つ場合,販売信号が生成されます.取引信号が発生すると,戦略はRSI値サイズに応じて取引することができます.

また,ストップ・ロスト,テイク・プロフィート,トレーリング・ストップ・ロストの機能も備わっている.ストップ・ロストはダウンサイドリスクを制御し,利益に利益をロックし,トレーリング・ストップは利益を実行できるようにする.これらの設定は,各取引のリスクを効果的に管理する.

利点

RSIの分散取引戦略には以下の利点があります.

  1. RSIの差異を把握することで,トレンド逆転を早期に検出できます.

  2. RSIは広く使用され,ほとんどの取引プラットフォームで利用可能である.この戦略は高度な適用性を持っています.

  3. RSIのパラメータは柔軟で,異なる市場状況に合わせて調整できます.

  4. ストップ・ロスト,テイク・プロフィット,ストップ・ロストのコントロールは リスクを効果的にコントロールします

  5. この戦略は 信号の周波数が適度で 過剰な取引は避けられます

  6. 論理はシンプルで 自動化プログラムも簡単です

リスク

この戦略にはいくつかのリスクもあります:

  1. RSIの偏差は完全に信頼性がないため,誤った信号を生む可能性があります.他のフィルターが必要です.

  2. 強い傾向の市場では,差異は失敗する可能性があります.これは避けるべきです.

  3. RSI パラメーターが不適切であれば 性能に影響を与えます 短期間すぎると 頻度とリスクが増加します

  4. ストップ・ロスの設定が 太りすぎると 利益が短くなり,太りすぎると リスクが限られなくなります.細かな調整が必要です.

  5. トレイリングストップは,不安定な市場では早めに停止することがあります.変動を考慮して合理的なトレリング幅が必要です.

リスクは以下の方法で軽減できます.

  1. MACDやボリンジャー帯などの指標を追加して 信号をフィルタリングし 誤った信号を減らす

  2. この戦略は,強烈なトレンドを避けるために,範囲限定の横向市場でのみ使用します.

  3. RSIのパラメータを最適化し,最適な回顧期間を選択し,異なる市場のためのパラメータをテストします.

  4. 合理的なストップ・ロストと 利益のレベルを設定する 歴史的なバックテストに基づいて

  5. 市場の変動とリスクに対する意欲に基づいて 後ろのストップ距離を調整する

最適化

戦略は以下の点で改善できる:

  1. 信号をフィルタリングし,信頼性を向上させるために他の指標を組み込む.

  2. 機械学習を利用して RSI パラメータを自動最適化します

  3. 市場体制に従って動的なストップ・ロスのアルゴリズムを設計します 範囲のストップがより広く,トレンド市場のストップがより狭いです

  4. 動的ポジションサイズモデルを構築し,ポジションサイズを調整する.

  5. 価格変動をベースにトレイル距離を設定するためにトレイルストップに波動性を導入します

  6. 外国為替や暗号通貨などの他の市場にも戦略を展開します

  7. 自動化のための定量的な取引システムを開発する

結論

RSIダイバージェンス・トレーディング戦略は,RSIと価格の間のダイバージェンスを特定することによってシグナルを生成する.論理は単純で自動化が容易である.ストップ・ロスト,テイク・プロフィート,トレーリング・ストップはリスクを効果的に制御する.しかし,この戦略には正確性とトレンド市場の限界がある.パラメータを最適化し,フィルターとダイナミック・ストップを追加することによって改善が可能である.技術戦略として,システム化された場合,レンジ・バインド市場では補完として役立つ.


/*backtest
start: 2023-09-24 00:00:00
end: 2023-10-24 00:00:00
period: 4h
basePeriod: 15m
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/
// © faytterro

//@version=5
// strategy("RSI Divergence Strategy", overlay=true, scale = scale.none)
rsilen=input.int(14, title="rsi length")
rsisrc=input(close, title="source")
x=ta.rsi(rsisrc,rsilen)
len=input.int(14, title="RSI Divergence length", maxval=500)
tpb = input.float(25, title="take profit", group = "buy", step = 0.5)
sb = input.float(5, title="stop", group = "buy", step = 0.5)
tsb = input.float(0.25, title="trailing stop", group = "buy", step = 0.5)
tps = input.float(25, title="take profit", group = "sell", step = 0.5)
ss =input.float(5, title="stop", group = "sell", step = 0.5)
tss = input.float(0.25, title="trailing stop", group = "sell", step = 0.5)
src=close
extrapolation=0
zoom=input.int(0, title="zoom", maxval=27, minval=-27)
hline(300-zoom*10, color=color.rgb(54, 58, 69, 100))
hline(10, color=color.rgb(54, 58, 69, 100))
// for ax+b
xo=0.0
yo=0.0
xyo=0.0
xxo=0.0
for i=0 to len-1
    xo:= xo + i/(len)
    yo:= yo + x[len-1-i]/(len)
    xyo:= xyo + i*x[len-1-i]/(len)
    xxo:= xxo + i*i/(len)
dnm=ta.lowest(low,200)
dizi=array.new_float(len*2+1+extrapolation)
// linedizi=array.new_line()
a=(xo*yo-xyo)/(xo*xo-xxo)
b=yo-a*xo
for i=0 to len-1+extrapolation
    array.set(dizi,i,a*i+b)
//// for src
// for ax+b
xo2=0.0
yo2=0.0
xyo2=0.0
xxo2=0.0
for i=0 to len-1
    xo2:= xo2 + i/(len)
    yo2:= yo2 + src[len-1-i]/(len)
    xyo2:= xyo2 + i*src[len-1-i]/(len)
    xxo2:= xxo2 + i*i/(len)

dizi2=array.new_float(len*2+1+extrapolation)
// linedizi2=array.new_line()
a2=(xo2*yo2-xyo2)/(xo2*xo2-xxo2)
b2=yo2-a*xo2
for i=0 to len-1+extrapolation
    array.set(dizi2,i,a2*i+b2)
ttk=((array.get(dizi,0)<array.get(dizi,1)) and (array.get(dizi2,0)>array.get(dizi2,1)))? 1 : 
 ((array.get(dizi,0)>array.get(dizi,1)) and (array.get(dizi2,0)<array.get(dizi2,1)))? -1 : 0
cg=((array.get(dizi,0)<array.get(dizi,1)) and (array.get(dizi2,0)>array.get(dizi2,1)))// and ta.highest(ttk[1],len/2)<1)
cr=((array.get(dizi,0)>array.get(dizi,1)) and (array.get(dizi2,0)<array.get(dizi2,1)))// and ta.lowest(ttk[1],len/2)>-1)
bgcolor(color=(cg and ta.highest(ttk[1],len/2)<1)? color.rgb(76, 175, 79, 50) : 
 (cr and ta.lowest(ttk[1],len/2)>-1)? color.rgb(255, 82, 82, 50) : na, offset=0, display=display.none)
plot(x)

// for ax+b
xo3=0.0
yo3=0.0
xyo3=0.0
xxo3=0.0
for i=0 to len-1
    xo3:= xo3 + i/(len)
    yo3:= yo3 + x[len-1-i+(ta.barssince(cg))]/(len)
    xyo3:= xyo3 + i*x[len-1-i+(ta.barssince(cg))]/(len)
    xxo3:= xxo3 + i*i/(len)

dizi3=array.new_float(len*2+1+extrapolation)
// linedizi3=array.new_line()
a3=(xo3*yo3-xyo3)/(xo3*xo3-xxo3)
b3=yo3-a3*xo3
for i=0 to len-1+extrapolation
    array.set(dizi3,i,a3*i+b3)

// for ax+b
xo4=0.0
yo4=0.0
xyo4=0.0
xxo4=0.0
for i=0 to len-1
    xo4:= xo4 + i/(len)
    yo4:= yo4 + x[len-1-i+(ta.barssince(cr))]/(len)
    xyo4:= xyo4 + i*x[len-1-i+(ta.barssince(cr))]/(len)
    xxo4:= xxo4 + i*i/(len)

dizi4=array.new_float(len*2+1+extrapolation)
// linedizi4=array.new_line()
a4=(xo4*yo4-xyo4)/(xo4*xo4-xxo4)
b4=yo4-a4*xo4
for i=0 to len-1+extrapolation
    array.set(dizi4,i,a4*i+b4)

// line=line.new((last_bar_index-ta.barssince(cg)-len),
//  array.get(dizi3,0), 
//  last_bar_index-ta.barssince(cg),
//  array.get(dizi3,len-1), color=color.rgb(0,255,0), width=2)
// line2=line.new((last_bar_index-ta.barssince(cr)-len),
//  array.get(dizi4,0), 
//  last_bar_index-ta.barssince(cr),
//  array.get(dizi4,len-1), color=color.rgb(255, 0, 0, 0), width=2)
// line.delete(line[1])
// line.delete(line2[1])

alert=((array.get(dizi,0)<array.get(dizi,1)) and (array.get(dizi2,0)>array.get(dizi2,1)) and ta.highest(ttk[1],len/2)<1)
 or ((array.get(dizi,0)>array.get(dizi,1)) and (array.get(dizi2,0)<array.get(dizi2,1)) and ta.lowest(ttk[1],len/2)>-1)
alertcondition(alert)
hline(50)
rs=hline(30)
rss=hline(70)
fill(rs, rss, color=color.rgb(126, 87, 194, 90), title="RSI Background Fill")

longCondition = cg and ta.highest(ttk[1],len/2)<1 
if (longCondition)
    strategy.entry("Long", strategy.long)
    strategy.exit("exit long", "Long", limit = close*(100+tpb)/100 , stop =close*(100-sb)/100 , trail_price = close , trail_offset = close*tsb)

shortCondition = cr and ta.lowest(ttk[1],len/2)>-1 
if (shortCondition)
    strategy.entry("Short", strategy.short)
    strategy.exit("exit short", "Short", limit = close*(100-tps)/100, stop = close*(100+ss)/100, trail_price = close , trail_offset = close*tss)


もっと