The MACD Trend Prediction Strategy is a trend following strategy based on the MACD indicator and EMA indicator. Unlike traditional MACD strategies that generate trading signals by crossing signal lines, this strategy generates trading signals by changes in the distance between the MACD line and signal line to capture trend changes.
Calculate fast line DEMAfast: Calculate two EMA values of the fast line MMEfast, and calculate the fast line DEMAfast according to the formula DEMAfast = ((2 * MMEfast) - MMEfastb).
Calculate slow line DEMAslow: Calculate two EMA values of the slow line MMEslow, and calculate the slow line DEMAslow according to the formula DEMAslow = ((2 * MMEslow) - MMEslowb).
Calculate MACD line: The MACD line is the difference between fast line DEMAfast and slow line DEMAslow, LigneMACDZeroLag.
Calculate signal line: Calculate two EMA values of MACD line MMEsignal, and calculate signal line Lignesignal according to the formula Lignesignal = ((2 * MMEsignal) - MMEsignalb).
Compare MACD line and signal line: Generate buy signal when MACD line is greater than signal line, and generate sell signal when MACD line is less than signal line.
The above calculation uses the DEMA algorithm, which can effectively reduce the lag of MACD indicator.
Using the DEMA algorithm can reduce the lag of the MACD indicator and make trading signals more sensitive.
It does not rely on MACD crossover signals, but captures trend changes through distance changes between MACD and signal lines, which can enter trends earlier.
The strategy accurately judges the trend, and the profit factor can reach 1.6-3.5 with good profitability.
The strategy logic is simple and clear, easy to understand and implement, suitable for quantitative trading.
As a lagging indicator, MACD may generate a lot of invalid trading signals in range-bound markets.
Although DEMA algorithm reduces lag, it cannot completely eliminate lag. There is still some lag.
As a trend following strategy, the profit may not be good in ranging markets.
The parameters sma, lma, tsp need to be optimized for different periods and varieties.
Stop loss strategies may need to be added to control losses.
Optimize sma, lma, tsp parameters to adapt to different periods and trading varieties.
Add dynamic stop loss strategies like ATR to control per trade loss.
Incorporate trend judgment indicators to avoid trading in ranging markets.
Add position sizing to adjust positions based on market volatility.
Optimize entry and exit logic to refine trading signal rules.
The MACD Trend Prediction Strategy improves the calculation of MACD by using the DEMA algorithm to reduce lag, and judges the trend through distance changes between MACD and signal lines. As a trend following strategy, it can effectively capture trend changes. The profit factor can reach 1.6-3.5, with certain advantages. But it still needs further optimization of parameters, stop loss strategies, filtering ranging markets, etc. to adapt to more market environments. This will be the development direction of this strategy.
/*backtest start: 2022-10-26 00:00:00 end: 2023-11-01 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/ // © moritz1301 //@version=4 strategy("MACD Trendprediction Strategy V1", shorttitle="MACD TPS", overlay=true) sma = input(12,title='DEMA Courte') lma = input(26,title='DEMA Longue') tsp = input(9,title='Signal') dolignes = input(true,title="Lignes") MMEslowa = ema(close,lma) MMEslowb = ema(MMEslowa,lma) DEMAslow = ((2 * MMEslowa) - MMEslowb ) MMEfasta = ema(close,sma) MMEfastb = ema(MMEfasta,sma) DEMAfast = ((2 * MMEfasta) - MMEfastb) LigneMACDZeroLag = (DEMAfast - DEMAslow) MMEsignala = ema(LigneMACDZeroLag, tsp) MMEsignalb = ema(MMEsignala, tsp) Lignesignal = ((2 * MMEsignala) - MMEsignalb ) MACDZeroLag = (LigneMACDZeroLag - Lignesignal) bgcolor(LigneMACDZeroLag<Lignesignal ? color.red : color.green) if (LigneMACDZeroLag>Lignesignal) strategy.entry("Buy", strategy.long, comment="BUY") if (LigneMACDZeroLag<Lignesignal) strategy.close("Buy", strategy.long, comment="SELL")