
이 전략은 RSI2 지표와 이동 평균을 결합한 거래 시스템이다. 그것은 주로 RSI 지표가 과매도 영역에서 반전 신호를 모니터링하여 잠재적인 더 많은 기회를 포착하고, 이동 평균을 트렌드 필터로 결합하여 거래의 정확성을 향상시킵니다. 이 전략은 고정된 퇴출 메커니즘을 채택하고, 포지션 보유 기간이 완료되면 자동으로 포지션을 평정합니다.
전략의 핵심 논리에는 다음과 같은 핵심 요소가 포함됩니다.
이것은 RSI 초상 판매 반전 신호와 함께 평행 경향 필터링을 통해 시장 기회를 잡기 위해 구조적이고 논리적으로 명확한 거래 전략입니다. 전략의 장점은 변수의 유연성, 바람 통제가 합리적이지만 여전히 가짜 돌파의 위험과 변수 민감성에 주의해야 합니다. 제안 된 최적화 방향을 통해 전략에는 더 많은 개선 공간이 있으며, 다양한 시장 환경에서의 적응력을 더욱 향상시킬 수 있습니다.
/*backtest
start: 2024-02-21 00:00:00
end: 2025-02-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/
//@version=6
strategy("RSI 2 Strategy with Fixed Lines and Moving Average Filter", overlay=true)
// Input parameters
rsiPeriod = input.int(2, title="RSI Period", minval=1)
rsiBuyLevel = input.float(25, title="RSI Buy Level", minval=0, maxval=100)
maxBarsToHold = input.int(5, title="Max Candles to Hold", minval=1)
maPeriod = input.int(50, title="Moving Average Period", minval=1) // Moving Average Period
useMAFilter = input.bool(true, title="Use Moving Average Filter") // Enable/Disable MA Filter
// RSI and Moving Average calculation
rsi = ta.rsi(close, rsiPeriod)
ma = ta.sma(close, maPeriod)
// Moving Average filter conditions
maFilterCondition = useMAFilter ? close > ma : true // Condition: price above MA
// Buy conditions
rsiIncreasing = rsi > rsi[1] // Current RSI greater than previous RSI
buyCondition = rsi[1] < rsiBuyLevel and rsiIncreasing and strategy.position_size == 0 and maFilterCondition
// Variables for management
var int barsHeld = na // Counter for candles after purchase
var float buyPrice = na // Purchase price
// Buy action
if buyCondition and na(barsHeld)
strategy.entry("Buy", strategy.long)
barsHeld := 0
buyPrice := close
// Increment the candle counter after purchase
if not na(barsHeld)
barsHeld += 1
// Sell condition after the configured number of candles
sellCondition = barsHeld >= maxBarsToHold
if sellCondition
strategy.close("Buy")
// Reset variables after selling
barsHeld := na
buyPrice := na