
이 전략은 쌍평평선 크로스, RSI 오버 바이 오버 세일, ATR 변동율 필터를 결합한 복합형 거래 시스템이다. 시스템은 단기 및 장기 이동 평균을 사용하여 거래 신호를 발생시키고, RSI 지표를 통해 시장 상태를 필터링하고, ATR 지표를 사용하여 변동율 판단을 하고, 지위 관리 및 위험 통제를 위해 백분율 스톱 손실과 위험 수익률과 결합한다. 이 전략은 강력한 적응력을 가지고 있으며, 시장 환경에 따라 변수를 유연하게 조정할 수 있다.
전략의 핵심 논리는 다음과 같은 측면에 기초합니다.
이 전략은 여러 기술적 지표를 조합하여 비교적 완전한 거래 시스템을 구축한다. 전략은 트렌드 시장에서 우수한 성능을 발휘하며, 좋은 위험 제어 능력을 가지고 있다. 전략은 합리적으로 매개 변수를 설정하고 필요한 필터링 조건을 추가함으로써 다양한 시장 환경에 적응할 수 있다. 실물 사용 전에 충분한 피드백과 매개 변수 최적화를 수행하는 것이 좋습니다.
/*backtest
start: 2025-01-21 00:00:00
end: 2025-02-20 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"SOL_USDT"}]
*/
//@version=5
strategy("Simplified MA Crossover Strategy with Disable Options", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// Inputs
shortLength = input.int(9, title="Short MA Length", minval=1)
longLength = input.int(21, title="Long MA Length", minval=1)
// RSI Filter
enableRSI = input.bool(true, title="Enable RSI Filter")
rsiLength = input.int(14, title="RSI Length", minval=1)
rsiOverbought = input.int(70, title="RSI Overbought Level", minval=50, maxval=100)
rsiOversold = input.int(30, title="RSI Oversold Level", minval=0, maxval=50)
// ATR Filter
enableATR = input.bool(true, title="Enable ATR Filter")
atrLength = input.int(14, title="ATR Length", minval=1)
minATR = input.float(0.005, title="Minimum ATR Threshold", minval=0)
// Risk Management
stopLossPerc = input.float(0.5, title="Stop Loss (%)", minval=0.1) / 100
riskRewardRatio = input.float(2, title="Risk-Reward Ratio", minval=1)
riskPercentage = input.float(2, title="Risk Percentage", minval=0.1) / 100
// Indicators
shortMA = ta.sma(close, shortLength)
longMA = ta.sma(close, longLength)
rsi = ta.rsi(close, rsiLength)
atr = ta.atr(atrLength)
// Conditions
longCondition = ta.crossover(shortMA, longMA)
shortCondition = ta.crossunder(shortMA, longMA)
// Apply RSI Filter (if enabled)
if (enableRSI)
longCondition := longCondition and rsi < rsiOverbought
shortCondition := shortCondition and rsi > rsiOversold
// Apply ATR Filter (if enabled)
if (enableATR)
longCondition := longCondition and atr > minATR
shortCondition := shortCondition and atr > minATR
// Risk Management
positionSize = strategy.equity * riskPercentage / (stopLossPerc * close)
takeProfitLevel = strategy.position_avg_price * (1 + stopLossPerc * riskRewardRatio)
stopLossLevel = strategy.position_avg_price * (1 - stopLossPerc)
// Execute Trades
if (longCondition)
strategy.entry("Long", strategy.long, qty=positionSize)
strategy.exit("Take Profit/Stop Loss", "Long", limit=takeProfitLevel, stop=stopLossLevel)
if (shortCondition)
strategy.entry("Short", strategy.short, qty=positionSize)
strategy.exit("Take Profit/Stop Loss", "Short", limit=strategy.position_avg_price * (1 - stopLossPerc * riskRewardRatio), stop=strategy.position_avg_price * (1 + stopLossPerc))
// Plotting
plot(shortMA, color=color.blue, title="Short MA")
plot(longMA, color=color.red, title="Long MA")
hline(rsiOverbought, "Overbought", color=color.red)
hline(rsiOversold, "Oversold", color=color.green)
plot(atr, color=color.orange, title="ATR")
plotshape(series=longCondition, title="Long Entry", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=shortCondition, title="Short Entry", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")