
双方向RSI突破戦略は,RSI指標を使用して価格の逆転点を識別するアルゴリズム取引戦略である.これは,RSI指標を設定された上下下下値と比較して,市場が超買超売りしているかどうかを判断し,取引シグナルを発信する.
この戦略は,主にRSI指数による判断である. RSI指数は,特定の周期内の閉盘価格の変化に基づいて計算され,それは株式の買取力を反映する. RSI上での設定された上値 (デフォルト75) を突破すると,株式が超買い領域に入ることを示す.
戦略的な判断のルール:
取引ロジックはシンプルで明快で,参照パラメータは合理的に設定され,配置スペースが広く,市場における大きなトレンドを捕捉するのに適しています.
この戦略の利点は以下の通りです.
総じて,この戦略の参照パラメータは合理的に設定され,実行が簡単で,RSI指標によって価格逆転を効果的に判断でき,中長線で市場の大きなトレンドを捕捉するのに適しており,使いやすい量化戦略である.
この戦略は単純で信頼性があるものの,潜在的なリスクも無視できない:
危険を抑えるために,注意すべき点は以下の通りです.
この戦略は,主に反転誤判と震動状況での損失のリスクを考慮して,以下のような点で最適化することができます.
双方向RSI突破策は,全体的に見ると,シンプルで実用的な量化策である.それは,RSI指標によって価格反転を判断し,簡単なトレンド追跡を実現している.ある程度の誤判リスクがあるにもかかわらず,パラメータ調整と信号フィルタリングによって最適化され,中長線トレンドを捕獲する上で重要な役割を果たしている.その論理は簡潔で,量化取引の初心者の参考学習に適している.この戦略は,最適化によって,比較的安定した量化利益を得ることを期待できる.
/*backtest
start: 2023-12-19 00:00:00
end: 2023-12-26 00:00:00
period: 3m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("RSI Algo", overlay=true)
// Calculate start/end date and time condition
DST = 1 //day light saving for usa
//--- Europe
London = iff(DST==0,"0000-0900","0100-1000")
//--- America
NewYork = iff(DST==0,"0400-1500","0500-1600")
//--- Pacific
Sydney = iff(DST==0,"1300-2200","1400-2300")
//--- Asia
Tokyo = iff(DST==0,"1500-2400","1600-0100")
//-- Time In Range
timeinrange(res, sess) => time(res, sess) != 0
london = timeinrange(timeframe.period, London)
newyork = timeinrange(timeframe.period, NewYork)
time_cond = true
myPeriod = input(defval=14, type=input.integer, title="Period")
myThresholdUp = input(defval=75, type=input.float, title="Upper Threshold")
myThresholdDn = input(defval=25, type=input.float, title="Lower Threshold")
myAlgoFlipToggle = input(defval=false, type=input.bool, title="Imverse Algorthim")
myLineToggle = input(defval=true, type=input.bool, title="Show Lines")
myLabelToggle = input(defval=true, type=input.bool, title="Show Labels")
myRSI=rsi(close, myPeriod)
buy = myAlgoFlipToggle ? falling(myRSI,1) and cross(myRSI, myThresholdDn) : rising(myRSI, 1) and cross(myRSI,myThresholdUp) //and time_cond
sell = myAlgoFlipToggle ? rising(myRSI, 1) and cross(myRSI,myThresholdUp) : falling(myRSI,1) and cross(myRSI, myThresholdDn) //and time_cond
myPosition = 0
myPosition := buy==1 ? 0 : sell==1 or myPosition[1]==1 ? 1 : 0
trendColor = buy ? color.red : sell ? color.green : na
plot(myLineToggle ? buy and myPosition[1]==1 ? low - 0.004: sell and myPosition[1]==0 ? high + 0.004 : na : na, color=trendColor, style=plot.style_line, linewidth=4, editable=false)
plotshape(myLabelToggle ? buy and myPosition[1]==1 ? low - 0.005 : na : na, style=shape.labelup, location=location.absolute, text="Buy", transp=0, textcolor = color.white, color=color.black, editable=false)
plotshape(myLabelToggle ? sell and myPosition[1]==0 ? high + 0.005 : na : na, style=shape.labeldown, location=location.absolute, text="Sell", transp=0, textcolor = color.white, color=color.black, editable=false)
strategy.initial_capital = 50000
//Calculate the size of the next trade
balance = strategy.netprofit + strategy.initial_capital //current balance
floating = strategy.openprofit //floating profit/loss
risk = input(2,type=input.float,title="Risk %")/100 //risk % per trade
isTwoDigit = input(false,"Is this a 2 digit pair? (JPY, XAU, XPD...")
stop = input(250, title="stop loss pips")
tp = input(2500, title="take profit pips")
if(isTwoDigit)
stop := stop/100
temp01 = balance * risk //Risk in USD
temp02 = temp01/stop //Risk in lots
temp03 = temp02*100000 //Convert to contracts
size = 1
strategy.entry("long",1,size,when=buy and myPosition[1]==1 )
strategy.entry("short",0,size,when=sell and myPosition[1]==0)
strategy.exit("exit_long","long",loss=stop, profit=tp) //Long exit (stop loss)
strategy.exit("exit_short","short",loss=stop, profit=tp) //Short exit (stop loss)
//strategy.close_all(when= not time_cond)