MACD长线反转策略是一个利用MACD指标识别价格长线反转,进行长线交易的策略。该策略使用MACD的快速SMA线和慢速SMA线差值构建MACD指标,并使用MACD指标的柱状线反转形态来识别价格潜在的长线反转机会。当识别到价格反转机会时,策略会进行方向性的长线入场。
该策略使用6日EMA作为MACD快线,26日EMA作为MACD慢线,快线和慢线的差值为MACD,再计算MACD的9日SMA构成信号线。快慢线差值即柱状线为零时代表平衡,为正代表长线看涨,为负代表长线看跌。
该策略的交易逻辑是:当MACD的柱状线上涨超过前一根柱状线时(差值扩大),认为价格反转为长线看涨(买入时机);当MACD的柱状线下跌超过前一根柱状线时(差值收窄),认为价格反转为长线看跌(卖出时机)。为过滤虚假信号,该策略会等待两根柱状线的实际反转再进行入场。
MACD长线反转策略通过判断MACD柱状线的反转来捕捉价格的长线反转机会。该策略成功控制了长短周期冲突,以及避免追高杀跌的问题。但是作为单一指标策略,MACD长线反转策略也存在一定局限性,仍有进一步优化的空间,特别是与其他指标组合使用。
/*backtest
start: 2022-12-08 00:00:00
end: 2023-12-14 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TheGrindToday
//@version=4
strategy("MACD Long Strat", overlay=false)
//fast = 12, slow = 26
fast = 6, slow = 26
fastMA = ema(close, fast)
slowMA = ema(close, slow)
macd = fastMA - slowMA
signal = sma(macd, 9)
histogram = macd-signal
macdpos = histogram[0] > 0
macdneg = histogram[0] < 0
histogram_reversing_negative = histogram[1] > histogram[2]
LongEntryCondition = histogram > histogram[1]
ShortEntryCondition = histogram < histogram[1]
exitConditionLong = histogram[0] < histogram[2]
if (LongEntryCondition and histogram_reversing_negative)
strategy.entry("Long", strategy.long)
if (exitConditionLong)
strategy.close("Long")
plot(histogram)