
双方向RSI均線回帰策は,超買と超売を識別するために,2つの異なる時間周期のRSI指標を使用するトレンド追跡策である.この戦略は,超売後に多額を出し,超買後に空白をすることで利益を得るように意図されている.この戦略は,平滑の異常に移動平均,RSI指標とポジション開設のカラーフィルターを使用して取引の機会を識別する.
この戦略は,異なる周期を持つ2つのRSI指標を使用して,1つの5分チャートと1時間のチャートに1つをピッチします. RSI指標では,オーバーセールレベルは30以下で,オーバーバイレベルは70以上と認識されます.
RSI値を追跡し,RSIが周期的に超売りまたは超買い領域にある場合を探し,拡大の超売りまたは超買い状態を示します.
さらに,平滑な異動移動平均を用いて,取引に入る前に一定の周期の赤または緑のK線をチェックしてトレンドの方向を確認する. ポジション開設のカラーフィルターは,偽信号を避けるのに役立ちます.
RSIと滑動差と移動平均の条件が満たされているとき,この戦略は,超売り後に多めにし,超買い後に空白し,賭け価格が均線に戻る.
昼の終わりにポジションを外して,一晩中持たないようにする.
双方向RSI均線回帰戦略は,規則化方法による取引動力を採用している. 2つの時間枠,オーバーバイオーバーセール指標,K線形状分析,および開設フィルターの組み合わせによって,高確率の均線回帰の機会を識別することを目指している. 厳格なリスク管理と慎重なポジションコントロールは,利益を得ながら引き下げを制御するのに役立ちます.
/*backtest
start: 2023-09-01 00:00:00
end: 2023-09-30 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//Gidra
//2018
//@version=2
strategy(title = "Gidra's Vchain Strategy v0.1", shorttitle = "Gidra's Vchain Strategy v0.1", overlay = false, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 100)
//Settings
needlong = input(true, defval = true, title = "Long")
needshort = input(true, defval = true, title = "Short")
capital = input(100, defval = 100, minval = 1, maxval = 10000, title = "Lot, %")
rsiperiod = input(14, defval = 14, minval = 2, maxval = 100, title = "RSI period")
rsilimit = input(30, defval = 30, minval = 1, maxval = 50, title = "RSI limit")
rsibars = input(3, defval = 3, minval = 1, maxval = 20, title = "RSI signals")
useocf = input(true, defval = true, title = "Use Open Color Filter")
openbars = input(2, defval = 2, minval = 1, maxval = 20, title = "Open Color, Bars")
showrsi = input(true, defval = true, title = "Show indicator RSI")
fromyear = input(2018, defval = 2018, minval = 1900, maxval = 2100, title = "From Year")
toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")
frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")
tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month")
fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From Day")
today = input(31, defval = 31, minval = 01, maxval = 31, title = "To Day")
//Heikin Ashi Open/Close Price
o=open
c=close
h=high
l=low
haclose = (o+h+l+c)/4
haopen = na(haopen[1]) ? (o + c)/2 : (haopen[1] + haclose[1]) / 2
hahigh = max (h, max(haopen,haclose))
halow = min (l, min(haopen,haclose))
col=haopen>haclose ? red : lime
plotcandle(haopen, hahigh, halow, haclose, title="heikin", color=col)
//RSI
uprsi = rma(max(change(close), 0), rsiperiod)
dnrsi = rma(-min(change(close), 0), rsiperiod)
rsi = dnrsi == 0 ? 100 : uprsi == 0 ? 0 : 100 - (100 / (1 + uprsi / dnrsi))
uplimit = 100 - rsilimit
dnlimit = rsilimit
rsidn = rsi < dnlimit ? 1 : 0
rsiup = rsi > uplimit ? 1 : 0
//RSI condition
rsidnok = highest(rsidn, rsibars) == 1? 1 : 0
rsiupok = highest(rsiup, rsibars) == 1? 1 : 0
//Color Filter
bar = haclose > haopen ? 1 : haclose < haopen ? -1 : 0
gbar = bar == 1 ? 1 : 0
rbar = bar == -1 ? 1 : 0
openrbarok = sma(gbar, openbars) == 1 or useocf == false
opengbarok = sma(rbar, openbars) == 1 or useocf == false
//Signals
up = openrbarok and rsidnok
dn = opengbarok and rsiupok
lot = strategy.position_size == 0 ? strategy.equity / close * capital / 100 : lot[1]
//Indicator RSI
colbg = showrsi == false ? na : rsi > uplimit ? red : rsi < dnlimit ? lime : na
bgcolor(colbg, transp = 20)
//Trading
if up
strategy.entry("Long", strategy.long, needlong == false ? 0 : lot, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
if dn
strategy.entry("Short", strategy.short, needshort == false ? 0 : lot, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
if time > timestamp(toyear, tomonth, today, 23, 59)// or exit
strategy.close_all()