
이것은 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)