RSI区間突破戦略は,典型的なトレンド追跡戦略である.これは,相対的に強い指数 ((RSI) を主要な技術指標として使用し,RSIがオーバーバイまたはオーバーセール状態にあるときに,区間突破の機会を探してポジションを確立し,トレンド追跡の動作を実現する目的である.
この戦略は,主にRSI指標によって市場の超買い超売り状態を判断する. RSI指標の計算式は:RSI= ((上昇平均数/上昇平均数+下降平均数) ×100. 上昇平均数とは,過去N日間の収盘上昇の簡易移動平均であり,下降平均数とは,過去N日間の収盘減少の簡易移動平均である.
RSIが設定された超買線 (デフォルト80) より大きいときは,市場が超買状態にあることを示します. RSIが設定された超売り区間 (デフォルト35) より小さいときは,市場が超売り区間にあることを示します.
具体的には,戦略は2つのSMA平均線からRSI指標の傾向を判断します. 速線が下から上へ緩い線を突破し,同時にRSIが超売り区間を突破すると,多めにします. 速線が上から下へ緩い線を突破し,同時にRSIが超買線を突破すると,空白します. 戦略は,リスクを制御するために,止損線と停止線を設定します.
RSI区間突破策は,全体的に見ると,典型的なトレンド追跡策である. RSI指数によって,買い買いを判断し,双SMA平均線フィルター信号を出し,リスクを制御するために止損ストップを設定する. しかし,RSI指数には遅滞性の問題があり,さらにパラメータの設定が不適切であることも,戦略のパフォーマンスに影響を与える.
/*backtest
start: 2023-09-10 00:00:00
end: 2023-10-10 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
//strategy("Strategy RSI | Fadior", shorttitle="Strategy RSI", pyramiding=10, calc_on_order_fills=false, initial_capital=10000, default_qty_type=strategy.percent_of_equity, currency="USD", default_qty_value=100, overlay=false)
len = input(3, minval=1, title="RSI Length")
threshLow = input(title="Treshold Low", defval=35)
threshHigh = input(title="Treshold High", defval=80)
rsiLength1 = input(title="RSI Smoothing 1", defval=3)
rsiLength2 = input(title="RSI Smoothing 2", defval=5)
SL = input(title="Stop loss %", type=float, defval=.026, step=.001)
TP = input( defval=300)
// 3 40 70 2
// 14 40 70 2 16 0.05 50
src = close
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
plot(sma(rsi,rsiLength2), color=orange)
plot(sma(rsi,rsiLength1), color=green)
band1 = hline(threshHigh)
band0 = hline(threshLow)
fill(band1, band0, color=purple, transp=90)
strategy = input(type=bool, title="Long only ?", defval=true)
strategy.risk.allow_entry_in(strategy ? strategy.direction.long : strategy.direction.all)
longCondition = sma(rsi,rsiLength1) < threshLow and sma(rsi,rsiLength2) > sma(rsi,rsiLength2)[1]
if (longCondition)
strategy.entry("Long", strategy.long) //, qty=10)
strategy.exit("Close Long", "Long", stop=src-close*SL, profit=TP)
shortCondition = sma(rsi,rsiLength1) > threshHigh and sma(rsi,rsiLength2) < sma(rsi,rsiLength2)[1]
if (shortCondition)
strategy.entry("Short", strategy.short) //, qty=10)
strategy.exit("Close Short", "Short") //, stop=src-close*SL, profit=TP)