
この戦略は,MACD柱状図の動量から逸脱したトレンド反転取引システムである.K線形の変化とMACD柱状図の動量変化の関係を解析することによって,市場の反転信号を捉える.戦略の核心思想は,市場の動量衰退の兆候があるときに反転取引を行うことであり,その結果,トレンドが反転しようとしているときに前もって配置する.
この戦略の取引論理は,空白と多額の2つの方向に分かれています. 空白条件:大きな陽線 (閉盤価格が開盤価格より高い) が出現し,その実体は前K線より大きく,またMACD柱状図が3連期の連続で下降傾向を示しているとき,上振動力が弱まっていることを示し,システムは空白信号を発する. 多条件化:大きな陰線 (閉盤価格が開盤価格より低い) が出現し,その実体は前K線より大きく,MACD柱状図が3連期の連続で上昇傾向を示しているとき,下落の動きが弱まっていることを示し,システムは多信号を発する. 持仓管理は,対抗信号平仓メカニズムを採用し,すなわち,逆の方向の取引信号が発生したときに,現在の持仓を平らげる. 戦略は,止損と停止を設定せず,完全に信号に依存してポジションを管理する.
この戦略は,K線形とMACD柱状の動量変化を組み合わせて市場の逆転機会を捕捉し,操作の簡潔さ,信号の明瞭性の特徴を有する.一定のリスクがあるものの,合理的な最適化とリスク管理措置によって,戦略の安定性と収益性を大幅に向上させることができる.戦略は,傾向が顕著な市場環境に特に適しており,取引システムの重要な構成要素として使用できる.
/*backtest
start: 2024-11-10 00:00:00
end: 2025-02-19 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//@version=5
strategy("MACD Momentum Reversal Strategy", overlay=true, initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// === MACD Calculation ===
fastLength = input.int(12, "MACD Fast Length")
slowLength = input.int(26, "MACD Slow Length")
signalLength = input.int(9, "MACD Signal Length")
[macdLine, signalLine, histLine] = ta.macd(close, fastLength, slowLength, signalLength)
// === Candle Properties ===
bodySize = math.abs(close - open)
prevBodySize = math.abs(close[1] - open[1])
candleBigger = bodySize > prevBodySize
bullishCandle = close > open
bearishCandle = close < open
// === MACD Momentum Conditions ===
// For bullish candles: if the MACD histogram (normally positive) is decreasing over the last 3 bars,
// then the bullish momentum is fading – a potential short signal.
macdLossBullish = (histLine[2] > histLine[1]) and (histLine[1] > histLine[0])
// For bearish candles: if the MACD histogram (normally negative) is increasing (moving closer to zero)
// over the last 3 bars, then the bearish momentum is fading – a potential long signal.
macdLossBearish = (histLine[2] < histLine[1]) and (histLine[1] < histLine[0])
// === Entry Conditions ===
// Short entry: Occurs when the current candle is bullish and larger than the previous candle,
// while the MACD histogram shows fading bullish momentum.
enterShort = bullishCandle and candleBigger and macdLossBullish
// Long entry: Occurs when the current candle is bearish and larger than the previous candle,
// while the MACD histogram shows fading bearish momentum.
enterLong = bearishCandle and candleBigger and macdLossBearish
// === Plot the MACD Histogram for Reference ===
plot(histLine, title="MACD Histogram", color=color.blue, style=plot.style_histogram)
// === Strategy Execution ===
// Enter positions based on conditions. There is no stop loss or take profit defined;
// positions remain open until an opposite signal occurs.
if (enterShort)
strategy.entry("Short", strategy.short)
if (enterLong)
strategy.entry("Long", strategy.long)
// Exit conditions: close an existing position when the opposite signal appears.
if (strategy.position_size > 0 and enterShort)
strategy.close("Long")
if (strategy.position_size < 0 and enterLong)
strategy.close("Short")