Type/to search

MACD Strategy - Two Way Exit Trading

Cryptocurrency
Created: 2023-12-12 12:44:50
Last modified: 3 years ago
1
Follow
1779
Followers

img

Overview

This strategy uses the Moving Average Convergence Divergence (MACD) indicator to generate long and short signals and makes reversal trades under good trend conditions by dynamically setting exit points to capture profits.

Strategy Principles

The core of this strategy is based on the MACD golden cross for long signals and death cross for short signals. Specifically, when the MACD line crosses above the signal line from below, a golden cross is generated as a long signal; when the MACD line crosses below the signal line from above, a death cross is generated as a short signal.

On golden cross signals, go long if the close price is above the EMA; on death cross signals, go short if the close price is below the EMA. This ensures reversal trades under an upward trend.

After entering positions, the strategy utilizes stop loss and take profit to dynamically control exits. Specifically, the stop loss for long positions is set at entry price * (1 - max drawdown); take profit is set at entry price * (1 + TARGET_STOP_RATIO * max drawdown). Vice versa for short positions. Here max drawdown is dynamically calculated as the percentage of price decline from swing low to close; TARGET_STOP_RATIO is default to 2, meaning a risk/reward ratio of 2.

The advantage of this dynamic stop strategy is that it can adjust stop loss and risk/reward ratio based on market volatility. It exits fast with a tight stop loss during high volatility while tracks profit with loose stop during low volatility environments.

Advantages

  1. MACD is an effective indicator for identifying reversal opportunities.

  2. The EMA filter ensures long trades happen only in an upward trend market.

  3. The dynamic exit control system maximizes profit while effectively manages risk.

  4. Fast exist speed reduces required monitoring time, making it suitable for busy investors.

Risks and Solutions

  1. MACD oscillates frequently during sideways markets, generating fake signals. This is solved by adding EMA filter to avoid counter-trend trades.

  2. Extreme volatility can cause DYNAMIC STOP to be too loose. Consider fixed risk/reward ratio when facing extreme market moves.

  3. Limited profit margin per trade requires frequent trading. Investors need certain psychological endurance and time commitment. Can switch to higher time frames if too busy.

Optimization Directions

  1. Fine tune MACD parameters based on symbol characteristics to optimize signal quality.

  2. Test different moving averages as trend filter to find the optimal one.

  3. Test TARGET_STOP_RATIO calculation and max drawdown definition to optimize the exit strategy.

  4. Add other factors like volume, volatility etc. to improve signal quality.

  5. Explore machine learning models to extract more features and build adaptive multifactor models for smarter exits.

Conclusion

This strategy has strong practical value overall. With MACD as core trading signal, the add-on modules of trend filter and dynamic exit control can significantly improve MACD performance itself. Exit control is essential for strategy optimization and this strategy innovates substantially in this area. Well worth further research and application.

Source
Pine
/*backtest
start: 2022-12-05 00:00:00
end: 2023-12-11 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/
// © maxencetajet

//@version=5
Strategy parameters
Strategy parameters
Source
Risk/Reward
Risk per Trade %
Backtest Time Period
Filter Date Range of Backtest
Start Date
End Date
EMA
Length
number of past candles
Swing High
Swing Low
MACD
Fast Length
Slow Length
Signal Smoothing
Oscillator MA Type
Signal Line MA Type
Comment
All comments (0)
No data
No data
  • 1
iPhone Download
Forums
PINE Language
© 2015 - ∞ INVENTOR PTE LTD (SG)