
이 전략은 상대적으로 약한 지수 ((RSI) 를 기반으로 한 동적 평소 전략으로, 동적으로 상장 및 상장 조건을 설정하여 시장의 추세를 포착합니다. 이 전략은 RSI 지표가 과매매 수준을 넘어서면 거래 신호를 생성하며, 다른 RSI 수준에 평소 조건을 설정하여 거래 성능을 최적화하기 위해 독특한 동적 평소 메커니즘을 도입합니다. 이 전략은 완전한 다중 포지 거래 시스템을 사용하여 시장의 양방향 변동에서 거래 기회를 포착 할 수 있습니다.
전략의 핵심 논리에는 다음과 같은 핵심 구성 요소가 포함됩니다.
이것은 RSI 지표와 동적 평형 메커니즘을 통해 시장 기회를 포착하기 위해 합리적으로 설계된 동적 거래 전략이다. 전략의 주요 특징은 체계화도가 높고, 위험 관리가 완벽하며, 적응력이 강하다. 일부 고유한 위험이 있지만, 매개 변수 최적화 및 기능 확장으로 전략에는 여전히 큰 개선 공간이 있다. 안정적인 거래 시스템을 찾는 투자자에게는 고려할 가치가 있는 전략 프레임 워크이다.
/*backtest
start: 2024-10-01 00:00:00
end: 2024-10-31 23:59:59
period: 3h
basePeriod: 3h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("RSI Strategy with Close Levels", shorttitle="RSI Strat", overlay=true)
// RSI Input settings
rsiLength = input.int(14, title="RSI Length")
rsiOverbought = input.int(70, title="RSI Overbought Level")
rsiOversold = input.int(30, title="RSI Oversold Level")
rsiCloseLongLevel = input.int(60, title="RSI Level to Close Long Position")
rsiCloseShortLevel = input.int(40, title="RSI Level to Close Short Position")
// Calculate RSI
rsi = ta.rsi(close, rsiLength)
// Generate buy and sell signals based on RSI levels
buySignal = ta.crossover(rsi, rsiOversold)
sellSignal = ta.crossunder(rsi, rsiOverbought)
// Check if there are open positions
var bool inPosition = na
if (strategy.opentrades > 0)
inPosition := true
else
inPosition := false
// Open long position on buy signal if not already in a position
if (buySignal and not inPosition)
strategy.entry("Buy", strategy.long)
inPosition := true
// Close long position on sell signal or when RSI reaches the close long level
if (inPosition and strategy.position_size > 0 and (sellSignal or rsi >= rsiCloseLongLevel))
strategy.close("Buy")
inPosition := false
// Open short position on sell signal if not already in a position
if (sellSignal and not inPosition)
strategy.entry("Sell", strategy.short)
inPosition := true
// Close short position on buy signal or when RSI reaches the close short level
if (inPosition and strategy.position_size < 0 and (buySignal or rsi <= rsiCloseShortLevel))
strategy.close("Sell")
inPosition := false
// Plot buy and sell signals
//plotshape(series=buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
//plotshape(series=sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// Plot RSI for visualization
hline(rsiOverbought, "RSI Overbought", color=color.red)
hline(rsiOversold, "RSI Oversold", color=color.green)
hline(rsiCloseLongLevel, "RSI Close Long Level", color=color.blue)
hline(rsiCloseShortLevel, "RSI Close Short Level", color=color.purple)
plot(rsi, title="RSI", color=color.orange)