资源加载中... loading...

MACD-Supertrend Dual Confirmation Trend Following Trading Strategy

Author: ChaoZhang, Date: 2024-12-11 17:16:05
Tags: MACDATRSMA

img

Overview

This strategy is a dual-confirmation trend following trading system that combines MACD indicator with Supertrend indicator. The strategy determines entry points by comparing MACD line crossovers with signal line while considering Supertrend direction, incorporating fixed percentage stop-loss and take-profit levels for risk management. This dual-confirmation mechanism enhances the reliability of trading signals and effectively reduces interference from false signals.

Strategy Principle

The core logic of the strategy is based on the following key elements:

  1. Supertrend Indicator: Uses 20-period ATR and factor of 2 to calculate trend lines for determining current market trend direction.
  2. MACD Indicator: Employs classic 12/26/9 parameter settings, generating trading signals through fast and slow line crossovers.
  3. Entry Conditions: Buy orders are triggered only when MACD fast line crosses above slow line (buy signal) and Supertrend direction is upward (direction==1).
  4. Risk Management: Sets 0.5% stop-loss and 99.99% take-profit levels for each trade to protect capital and secure profits.

Strategy Advantages

  1. Dual Confirmation Mechanism: Significantly improves trading signal accuracy by combining trend following (Supertrend) and momentum (MACD) indicators.
  2. Strong Adaptability: Supertrend indicator automatically adjusts parameters based on market volatility through ATR calculations.
  3. Comprehensive Risk Control: Percentage-based stop-loss strategy ensures controllable risk per trade.
  4. Clear Execution Logic: Well-defined entry and exit conditions minimize subjective judgment interference.
  5. Simple Operation: Strategy logic is intuitive, facilitating practical operation and monitoring.

Strategy Risks

  1. Trend Dependency: May generate frequent false signals in ranging markets, increasing trading costs.
  2. Lag Risk: Both MACD and Supertrend are lagging indicators, potentially responding slowly to rapid market reversals.
  3. Fixed Stop-Loss Risk: Fixed percentage stop-loss may not adequately adapt to volatility characteristics in different market environments.
  4. Parameter Sensitivity: Strategy effectiveness depends on multiple parameter settings, requiring continuous optimization.

Strategy Optimization Directions

  1. Dynamic Stop-Loss Optimization: Recommend replacing fixed stop-loss with ATR-based dynamic stop-loss for better market adaptation.
  2. Market Environment Filtering: Add volatility indicators (e.g., VIX) as market environment filters to adjust parameters or pause trading during high volatility.
  3. Volume-Price Relationship Integration: Consider incorporating volume indicators into signal confirmation system.
  4. Parameter Adaptation Optimization: Develop parameter adaptation mechanism based on market conditions.
  5. Position Management Enhancement: Introduce dynamic position sizing mechanism adjusting trade size based on market volatility and account equity.

Summary

The strategy constructs a relatively reliable trend following trading system by combining advantages of MACD and Supertrend indicators. The 46% accuracy rate and 46% return demonstrate profitable potential. Through suggested optimizations, particularly dynamic stop-loss and market environment filtering, strategy stability and adaptability can be further enhanced. Suitable for intraday and futures trading, users should note market environment compatibility and adjust parameters according to actual conditions.


/*backtest
start: 2024-11-10 00:00:00
end: 2024-12-09 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy('MANTHAN BHRAMASTRA', overlay=true)

// Supertrend function
f_supertrend(_period, _multiplier) =>
    atr = ta.sma(ta.tr, _period)
    upTrend = hl2 - _multiplier * atr
    downTrend = hl2 + _multiplier * atr
    var float _supertrend = na
    var int _trendDirection = na
    _supertrend := na(_supertrend[1]) ? hl2 : close[1] > _supertrend[1] ? math.max(upTrend, _supertrend[1]) : math.min(downTrend, _supertrend[1])
    _trendDirection := close > _supertrend ? 1 : -1
    [_supertrend, _trendDirection]

// Supertrend Settings
factor = input(2, title='Supertrend Factor')
atrLength = input(20, title='Supertrend ATR Length')

// Calculate Supertrend
[supertrendValue, direction] = f_supertrend(atrLength, factor)


// MACD Settings
fastLength = input(12, title='MACD Fast Length')
slowLength = input(26, title='MACD Slow Length')
signalSmoothing = input(9, title='MACD Signal Smoothing')

// Calculate MACD
[macdLine, signalLine, _] = ta.macd(close, fastLength, slowLength, signalSmoothing)

// Generate Buy signals
buySignal = ta.crossover(macdLine, signalLine) and direction == 1

// Plot Buy signals

// Calculate stop loss and take profit levels (0.25% of the current price)
longStopLoss = close * 0.9950
longTakeProfit = close * 1.9999

// Execute Buy orders with Target and Stop Loss
if buySignal
    strategy.entry('Buy', strategy.long)
    strategy.exit('Sell', 'Buy', stop=longStopLoss, limit=longTakeProfit)



Related

More