
RSI均線交差戦略は,暗号通貨取引に適用される戦略である.この戦略は,移動平均をRSI指標に適用し,RSIとその移動平均の交差に応じて買入と売却の信号を発する.
この戦略は,まずRSIを計算する. RSIは,価格の強さや弱さを反映した,一定の時間周期における上昇変化に基づいている. RSIは,70を超えると超買区,30を超えると超売り区である.
この戦略は,RSI指標に基づいて移動平均を適用します.移動平均は,ランダムな波動をフィルターして,トレンドの方向を判断します.ここでは,10サイクルRSI移動平均が設定されています.
RSI上の移動平均を突破すると,買入シグナルとみなされ,RSI下の移動平均を突破すると,売出シグナルとみなされます. この2つのシグナルに基づいて取引されます.
コードでは,まず length周期のRSI指標を計算します. そして,10周期のRSIの移動平均を計算します.
さらに,コードは,rsi,ma の線形図と,rsi-ma の柱形図を描いています.rsi=70,rsi=30 の境界線を描いています.そして,買取と販売の際に,図に対応する信号矢印をマークしています.
リスクに応じて,パラメータを調整し,指数の効果を最適化し,ポジションを適切に短縮し,ストップ・ローンを設定し,トレンド分析と連携してシグナルをフィルターすることができます.
RSI均線交差戦略は,トレンド指標とフィルター指標の優位性を組み合わせ,比較的成熟した信頼性がある.この戦略の論理は簡単で分かりやすく,コードの実装も完全で,全体的に言えば,より良い暗号通貨取引戦略である.しかし,どんな戦略にも最適化が必要な場所があり,継続的にテストして調整し,トレンド判断を補助して,より良い戦略効果を得る必要がある.
/*backtest
start: 2022-10-31 00:00:00
end: 2023-11-06 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("RSI w MA Strategy", shorttitle="RSI w MA Strategy", overlay=false, initial_capital=10000, currency='USD',process_orders_on_close=true)
//TIME FRAME AND BACKGROUND CONTROL/////////////////////////////////////////////
testStartYear = input(2019, "Backtest Start Year")
testStartMonth = input(01, "Backtest Start Month")
testStartDay = input(01, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear, testStartMonth, testStartDay, 0, 0)
testStopYear = input(2022, "Backtest Stop Year")
testStopMonth = input(1, "Backtest Stop Month")
testStopDay = input(1, "Backtest Stop Day")
testPeriodStop = timestamp(testStopYear, testStopMonth, testStopDay, 0, 0)
testPeriodBackground = input(title="Color Background?", type=input.bool, defval=true)
testPeriodBackgroundColor = testPeriodBackground and time >= testPeriodStart and time <= testPeriodStop ?
color.teal : na
//bgcolor(testPeriodBackgroundColor, transp=50)
testPeriod() => true
////////////////////////////////////////////////////////////////////////////////
src = close, len = input(27, minval=1, title="Length")
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))
window = input(10, "RSI MA Window")
ma = sma(rsi,window)
plot(rsi, color=color.orange)
colorr= ma > rsi ? color.red : color.green
plot(ma,color=colorr)
band1 = hline(70)
band0 = hline(30)
fill(band1, band0, color=color.purple, transp=90)
diff = rsi - ma
plot(diff,style= plot.style_columns,transp=50,color = colorr)
plotshape(crossunder(rsi,ma)?rsi:na,title="top",style=shape.triangledown,location=location.absolute,size=size.tiny,color=color.red,transp=0)
plotshape(crossover(rsi,ma)?rsi:na,title="bottom",style=shape.triangleup,location=location.absolute,size=size.tiny,color=color.lime,transp=0)
buySignal = crossover(rsi,ma)
sellSignal = crossunder(rsi,ma)
//TRADE CONTROL/////////////////////////////////////////////////////////////////
if testPeriod()
if buySignal
strategy.close("Short", qty_percent = 100, comment = "Close Short")
strategy.entry("Long", strategy.long, qty=.1)
if sellSignal
strategy.close("Long", qty_percent = 100, comment = "Close Long")
strategy.entry("Short", strategy.short, qty=.1)
////////////////////////////////////////////////////////////////////////////////