
この戦略は、相対力指数 (RSI) に基づいたトレンド反転取引システムです。買われすぎと売られすぎの範囲を設定することで市場の転換点を捉え、ATR ダイナミック ストップ ロスを組み合わせてリスクを管理します。この戦略のユニークさは、「禁止取引範囲」という概念を導入したことにあり、これにより、変動の激しい市場での頻繁な取引を効果的に回避できます。この戦略は、ボラティリティの高い市場環境、特に明らかなトレンド特性を持つ商品の取引に適しています。
この戦略は主に以下のコアロジックに基づいています。
この戦略は、RSI 反転シグナルと禁止取引範囲の革新的な組み合わせを通じて、トレンド取引におけるタイミングの問題を解決します。 ATR ダイナミック ストップ ロスの導入により、戦略に信頼性の高いリスク管理メカニズムが提供されます。この戦略には依然として潜在的なリスクが残っていますが、推奨される最適化の方向性を通じて、戦略の安定性と収益性をさらに向上させることができます。全体として、これは明確なロジックと強力な実用性を備えたトレンド反転取引戦略です。
/*backtest
start: 2024-12-19 00:00:00
end: 2024-12-26 00:00:00
period: 2h
basePeriod: 2h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("RSI-Based Trading Strategy with No Trading Zone and ATR Stop Loss", overlay=true)
// Input parameters
rsiPeriod = input(14, title="RSI Period")
rsiOverbought = input(60, title="RSI Overbought Level")
rsiOversold = input(40, title="RSI Oversold Level")
rsiExitBuy = input(45, title="RSI Exit Buy Level")
rsiExitSell = input(55, title="RSI Exit Sell Level")
atrPeriod = input(14, title="ATR Period")
atrMultiplier = input(1.5, title="ATR Stop Loss Multiplier")
// Calculate RSI and ATR
rsi = ta.rsi(close, rsiPeriod)
atr = ta.atr(atrPeriod)
// Buy conditions
buyCondition = ta.crossover(rsi, rsiOverbought) and close > high[1]
if (buyCondition and not strategy.position_size)
stopLossLevel = close - atr * atrMultiplier
strategy.entry("Buy", strategy.long, stop=stopLossLevel)
// Exit conditions for buy
exitBuyCondition = rsi < rsiExitBuy
if (exitBuyCondition and strategy.position_size > 0)
strategy.close("Buy")
// Sell conditions
sellCondition = ta.crossunder(rsi, rsiOversold) and close < low[1]
if (sellCondition and not strategy.position_size)
stopLossLevel = close + atr * atrMultiplier
strategy.entry("Sell", strategy.short, stop=stopLossLevel)
// Exit conditions for sell
exitSellCondition = rsi > rsiExitSell
if (exitSellCondition and strategy.position_size < 0)
strategy.close("Sell")
// Plotting RSI for visualization
hline(rsiOverbought, "Overbought", color=color.red)
hline(rsiOversold, "Oversold", color=color.green)
hline(rsiExitBuy, "Exit Buy", color=color.blue)
hline(rsiExitSell, "Exit Sell", color=color.orange)
plot(rsi, title="RSI", color=color.purple)
// // No Trading Zone
// var box noTradingZone = na
// // Create a rectangle for the no trading zone
// if (rsi >= rsiExitBuy and rsi <= rsiExitSell)
// // If the no trading zone box does not exist, create it
// if (na(noTradingZone))
// noTradingZone := box.new(bar_index, high, bar_index + 1, low, bgcolor=color.new(color.gray, 90), border_color=color.new(color.gray, 90))
// else
// // Update the existing box to cover the current candle
// box.set_left(noTradingZone, bar_index)
// box.set_right(noTradingZone, bar_index + 1)
// box.set_top(noTradingZone, high)
// box.set_bottom(noTradingZone, low)
// else
// // If the RSI is outside the no trading zone, delete the box
// if (not na(noTradingZone))
// box.delete(noTradingZone)
// noTradingZone := na