
この戦略は,RSI指標を計算し,超買超売区間を設定し,ダイナミックストップと目標利益の退出を組み合わせて,取引戦略を構築する. RSI指標上の超売区間を突破するときに空白し,超売区間を突破するときに多額にする. また,ストップと目標利益を追跡してポジションを退出する.
この戦略は,市場の技術的形状を判断するために14日RSI指標を使用する. RSI指標は,市場が超買いまたは超売りであるかを判断するために,一段の時間内に上昇と下降の動きの割合を反映する. この戦略のRSIの長さは14である. RSIが70を超えると,市場は超買いとみなされ,空売りとなる.
また,この戦略は,ダイナミックなストップトラッキングメカニズムを使用しています. 多頭ポジションを保有する場合は,ストップトラッキング価格が閉店価格の97%であり,空頭ポジションを保有する場合は,ストップトラッキング価格が閉店価格の103%です.
最後に,この戦略は,目標利益のメカニズムも使用する. 持仓利益が20%に達すると,ポジションを退出する. これは,利益の一部をロックして,利益の回転を避けることができる.
この戦略には以下の利点があります.
この戦略にはいくつかのリスクがあります.
上記のリスクは,RSIパラメータの最適化,ストップ幅の調整,目標利益要求の適切な緩和によって解決できます.
この戦略は以下の方向から最適化できます.
この戦略の全体的な考え方は明確で,RSI指標を使用して超買い超売を判断し,ダイナミックストップと目標利益退出を配合する。優点は,実装を理解しやすいこと,リスクがコントロールできる場所,拡張性強である。次のステップは,信号品質の向上,ダイナミック調整パラメータなどの方向から最適化することができ,戦略をより賢明にする。
/*backtest
start: 2024-01-04 00:00:00
end: 2024-02-03 00:00:00
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Modified RSI-Based Trading Strategy", overlay=true)
// RSI settings
rsiLength = input(14, title="RSI Length")
overboughtLevel = 70
oversoldLevel = 30
// User-defined parameters
trailingStopPercentage = input(3, title="Trailing Stop Percentage (%)")
profitTargetPercentage = input(20, title="Profit Target Percentage (%)")
rsiValue = ta.rsi(close, rsiLength)
var float trailingStopLevel = na
var float profitTargetLevel = na
// Entry criteria
enterLong = ta.crossover(rsiValue, oversoldLevel)
enterShort = ta.crossunder(rsiValue, overboughtLevel)
// Exit criteria
exitLong = ta.crossover(rsiValue, overboughtLevel)
exitShort = ta.crossunder(rsiValue, oversoldLevel)
// Trailing stop calculation
if (strategy.position_size > 0)
trailingStopLevel := close * (1 - trailingStopPercentage / 100)
if (strategy.position_size < 0)
trailingStopLevel := close * (1 + trailingStopPercentage / 100)
// Execute the strategy
if (enterLong)
strategy.entry("Buy", strategy.long)
if (exitLong or ta.crossover(close, trailingStopLevel) or ta.change(close) > profitTargetPercentage / 100)
strategy.close("Buy")
if (enterShort)
strategy.entry("Sell", strategy.short)
if (exitShort or ta.crossunder(close, trailingStopLevel) or ta.change(close) < -profitTargetPercentage / 100)
strategy.close("Sell")
// Plot RSI and overbought/oversold levels
plot(rsiValue, title="RSI", color=color.blue)
hline(overboughtLevel, "Overbought", color=color.red, linestyle=hline.style_dashed)
hline(oversoldLevel, "Oversold", color=color.green, linestyle=hline.style_dashed)