
この戦略は,技術分析の複数の重要な指標を組み合わせた総合的な取引システムであり,双均線システム ((SMA),移動平均の相似散度 ((MACD),相対的な強さ指数 ((RSI) とレジスタンス位分析を含む.戦略の核心思想は,多次元的な技術指標を使用して取引信号を確認し,市場情緒指標と組み合わせてポジション管理を最適化し,最終的に勝率とリスク/報酬率の向上を目指すことです.
戦略は,短期 (10日) と長期 (30日) の2つの単純な移動平均を主要なシグナルシステムとして採用する.短期平均線が長期平均線を上方へ横切ると,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.")