
この戦略は、相対力指数 (RSI) に基づいたマルチレベル インジケーター オーバーレイ取引システムです。この戦略は、特定の取引時間枠内で動作し、RSI インジケーターの買われすぎと売られすぎのシグナルを通じて取引機会を識別し、それを動的なポジション調整メカニズムと組み合わせて、市場が反対方向に動いたときにバッチでポジションを構築することで全体的な収益を最適化します。この戦略では、ストップ利益管理に平均エントリー価格に基づいた目標利益方式を使用します。
この戦略は主に以下のコアコンポーネントに基づいています。
この戦略は、RSI インジケーターとバッチ開始メカニズムを組み合わせることで、比較的完全な取引システムを形成します。この戦略の核心的な利点は、マルチレベルの信号フィルタリングメカニズムと柔軟なポジション管理方法にありますが、同時に、トレンド市場のリスクやパラメータの最適化などの問題にも注意を払う必要があります。トレンド フィルターの追加、ストップロス メカニズムの最適化、その他の改善により、戦略の全体的なパフォーマンスをさらに向上させることができます。
/*backtest
start: 2024-12-10 00:00:00
end: 2025-01-08 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":49999}]
*/
//@version=6
strategy("TonyM RSI", overlay=true)
// Input Settings
rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
rsiSourceInput = input.source(close, "Source", group="RSI Settings")
startHour = input.int(2, "Start Hour", minval=0, maxval=23, group="Trading Window")
endHour = input.int(4, "End Hour", minval=0, maxval=23, group="Trading Window")
// RSI Calculation
change = ta.change(rsiSourceInput)
up = ta.rma(math.max(change, 0), rsiLengthInput)
down = ta.rma(-math.min(change, 0), rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
// Time Filter
inTradingWindow = (hour >= startHour and hour < endHour)
// Strategy Settings
buyLevel = 30
sellLevel = 70
scaleDistance = 1.0 // Distance in points to add to the position
takeProfitPoints = 1.5 // Profit target from average price
initialQty = 1 // Initial trade size
scalingQty = 1 // Additional trade size for scaling
// Trade Logic
if inTradingWindow
// Entry Logic
if rsi <= buyLevel and strategy.position_size == 0
strategy.entry("Buy", strategy.long, qty=initialQty)
if rsi >= sellLevel and strategy.position_size == 0
strategy.entry("Sell", strategy.short, qty=initialQty)
// Scaling Logic
if strategy.position_size > 0 and close <= strategy.position_avg_price - scaleDistance
strategy.entry("Scale Buy", strategy.long, qty=scalingQty)
if strategy.position_size < 0 and close >= strategy.position_avg_price + scaleDistance
strategy.entry("Scale Sell", strategy.short, qty=scalingQty)
// Exit Logic (based on average price)
if strategy.position_size > 0
strategy.exit("Take Profit Long", "Buy", limit=strategy.position_avg_price + takeProfitPoints)
if strategy.position_size < 0
strategy.exit("Take Profit Short", "Sell", limit=strategy.position_avg_price - takeProfitPoints)
// Plot RSI
plot(rsi, "RSI", color=color.blue, linewidth=1)
rsiUpperBand = hline(70, "RSI Upper Band", color=color.red)
rsiLowerBand = hline(30, "RSI Lower Band", color=color.green)
fill(rsiUpperBand, rsiLowerBand, color=color.new(color.gray, 90))