
これは,RSI動量指標とATR波動指標を組み合わせた取引戦略システムである.この戦略は,RSIとその移動平均との交差を監視して潜在的な取引機会を識別し,同時にATR指標を波動率フィルターとして使用して,市場が十分な波動性を確保する.この戦略は,欧州取引時間 ((プラハ時間8:00-21:00) で動作し,5分間の周期を採用し,固定的ストップ・ロストレベルを設定している.
戦略の中核となるロジックは、次の主要な要素に基づいています。
取引の具体的ルールは以下の通りです.
この戦略は,RSIとATRの指標を組み合わせて,比較的完全な取引システムを構築している.戦略の主要な優位性は,複数のフィルタリング機構と完善なリスク管理にあるが,同時にいくつかの限界がある.提案された最適化の方向によって,戦略は,より良いパフォーマンスを得る見通しがある.鍵は,実際の取引環境に応じてパラメータを継続的に調整し,最適化し,戦略の適応性を維持することである.
/*backtest
start: 2024-11-10 00:00:00
end: 2024-12-09 08:00:00
period: 3h
basePeriod: 3h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Custom RSI + ATR Strategy", overlay=true)
// === Настройки индикаторов ===
rsi_length = input.int(14, minval=1, title="RSI Length")
rsi_ma_length = input.int(10, minval=1, title="RSI MA Length")
atr_length = input.int(14, minval=1, title="ATR Length")
atr_threshold = input.float(0.5, minval=0.1, title="ATR Threshold")
// === Параметры стоп-лосса и тейк-профита ===
stop_loss_ticks = input.int(5000, title="Stop Loss Ticks")
take_profit_ticks = input.int(5000, title="Take Profit Ticks")
// === Получение значений индикаторов ===
rsi = ta.rsi(close, rsi_length)
rsi_ma = ta.sma(rsi, rsi_ma_length)
atr_value = ta.atr(atr_length)
// === Время для открытия сделок ===
start_time = timestamp("Europe/Prague", year, month, dayofmonth, 8, 0)
end_time = timestamp("Europe/Prague", year, month, dayofmonth, 21, 0)
in_trading_hours = (time >= start_time and time <= end_time)
// === Условие по волатильности ===
volatility_filter = atr_value > atr_threshold
// === Условия для лонгов ===
long_condition = ta.crossover(rsi, rsi_ma) and rsi < 45 and in_trading_hours and volatility_filter
if (long_condition)
strategy.entry("Long", strategy.long)
strategy.exit("Take Profit/Stop Loss", "Long", stop=low - stop_loss_ticks * syminfo.mintick, limit=high + take_profit_ticks * syminfo.mintick)
// === Условия для шортов ===
short_condition = ta.crossunder(rsi, rsi_ma) and rsi > 55 and in_trading_hours and volatility_filter
if (short_condition)
strategy.entry("Short", strategy.short)
strategy.exit("Take Profit/Stop Loss", "Short", stop=high + stop_loss_ticks * syminfo.mintick, limit=low - take_profit_ticks * syminfo.mintick)
// === Отображение индикаторов на графике ===
plot(rsi, color=color.blue, title="RSI")
plot(rsi_ma, color=color.red, title="RSI MA")
hline(45, "RSI 45", color=color.green)
hline(55, "RSI 55", color=color.red)
plot(atr_value, color=color.orange, title="ATR", linewidth=2)
hline(atr_threshold, "ATR Threshold", color=color.purple)