
이 전략은 종합적인 거래 시스템으로, 기술 분석의 여러 핵심 지표를 결합합니다. 이중 평평선 시스템 (SMA), 이동 평균 동향 분산 (MACD), 상대적 강도 지수 (RSI) 및 저항점 분석을 포함합니다. 전략의 핵심 아이디어는 다차원 기술 지표를 통해 거래 신호를 확인하고, 시장 감정 지표와 결합하여 포지션 관리를 최적화하여 궁극적으로 승률과 위험 / 수익률을 높이는 것입니다.
이 전략은 단기 (10일) 과 장기 (30일) 의 두 가지 간단한 이동 평균을 주요 신호 시스템으로 사용합니다. 단기 평균이 장기 평균을 상향으로 가로질러 있고 MACD 지표가 다방면 동향을 표시 할 때 시스템에서 다중 신호를 발산합니다. 매출 조건은 저항점 분석과 결합되어 있으며, 가격이 지난 20주기의 최고점에 도달하고 MACD가 공백 신호를 표시 할 때 시스템이 평정됩니다. 또한, 전략은 RSI 지표를 감정 필터로 도입하여 포지션을 최적화합니다.
이 전략은 여러 클래식 기술 지표를 조합하여 완전한 거래 시스템을 구축한다. 전략의 장점은 다중 신호 확인 메커니즘과 완벽한 위험 제어 시스템이지만 여전히 시장 환경이 전략의 성과에 미치는 영향을 주의해야 한다. 제안된 최적화 방향을 통해 전략의 안정성과 적응력이 더욱 향상될 전망이다. 실장 응용에서는 투자자가 자신의 위험 선호와 시장 환경에 따라 적절한 매개 변수를 조정하고 항상 시장의 기본 사항에 대한 관심을 유지하도록 권장한다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-11 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("XAUUSD SMA with MACD & Market Sentiment (Enhanced RR)", overlay=true)
// Input parameters for moving averages
shortSMA_length = input.int(10, title="Short SMA Length", minval=1)
longSMA_length = input.int(30, title="Long SMA Length", minval=1)
// MACD settings
[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9)
// Lookback period for identifying major resistance (swing highs)
resistance_lookback = input.int(20, title="Resistance Lookback Period", tooltip="Lookback period for identifying major resistance")
// Calculate significant resistance (local swing highs over the lookback period)
major_resistance = ta.highest(close, resistance_lookback)
// Calculate SMAs
shortSMA = ta.sma(close, shortSMA_length)
longSMA = ta.sma(close, longSMA_length)
// RSI for market sentiment
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)
rsi = ta.rsi(close, rsiLength)
// Define buy condition based on SMA and MACD
buyCondition = ta.crossover(shortSMA, longSMA) and macdLine > signalLine
// Define sell condition: only sell if price is at or above the identified major resistance
sellCondition = close >= major_resistance and macdLine < signalLine
// Define sentiment-based exit conditions
closeEarlyCondition = strategy.position_size < 0 and rsi > rsiOverbought // Close losing trade early if RSI is overbought
holdWinningCondition = strategy.position_size > 0 and rsi < rsiOversold // Hold winning trade if RSI is oversold
// Execute strategy: Enter long position when buy conditions are met
if (buyCondition)
strategy.entry("Buy", strategy.long)
// Close the position when the sell condition is met (price at resistance)
if (sellCondition and not holdWinningCondition)
strategy.close("Buy")
// Close losing trades early if sentiment is against us
if (closeEarlyCondition)
strategy.close("Buy")
// Visual cues for buy and sell signals
plotshape(series=buyCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=sellCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// Add alert for buy condition
alertcondition(buyCondition, title="Buy Signal Activated", message="Buy signal activated: Short SMA has crossed above Long SMA and MACD is bullish.")
// Add alert for sell condition to notify when price hits major resistance
alertcondition(sellCondition, title="Sell at Major Resistance", message="Sell triggered at major resistance level.")
// Add alert for early close condition (for losing trades)
alertcondition(closeEarlyCondition, title="Close Losing Trade Early", message="Sentiment is against your position, close trade.")
// Add alert for holding winning condition (optional)
alertcondition(holdWinningCondition, title="Hold Winning Trade", message="RSI indicates oversold conditions, holding winning trade.")