Strategy vault / Trend following
MACD Supertrend Dual Confirmation Trend Following Trading Strategy
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…

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:
- Supertrend Indicator: Uses 20-period ATR and factor of 2 to calculate trend lines for determining current market trend direction.
- MACD Indicator: Employs classic 12/26/9 parameter settings, generating trading signals through fast and slow line crossovers.
- Entry Conditions: Buy orders are triggered only when MACD fast line crosses above slow line (buy signal) and Supertrend direction is upward (direction==1).
- Risk Management: Sets 0.5% stop-loss and 99.99% take-profit levels for each trade to protect capital and secure profits.
Strategy Advantages
- Dual Confirmation Mechanism: Significantly improves trading signal accuracy by combining trend following (Supertrend) and momentum (MACD) indicators.
- Strong Adaptability: Supertrend indicator automatically adjusts parameters based on market volatility through ATR calculations.
- Comprehensive Risk Control: Percentage-based stop-loss strategy ensures controllable risk per trade.
- Clear Execution Logic: Well-defined entry and exit conditions minimize subjective judgment interference.
- Simple Operation: Strategy logic is intuitive, facilitating practical operation and monitoring.
Strategy Risks
- Trend Dependency: May generate frequent false signals in ranging markets, increasing trading costs.
- Lag Risk: Both MACD and Supertrend are lagging indicators, potentially responding slowly to rapid market reversals.
- Fixed Stop-Loss Risk: Fixed percentage stop-loss may not adequately adapt to volatility characteristics in different market environments.
- Parameter Sensitivity: Strategy effectiveness depends on multiple parameter settings, requiring continuous optimization.
Strategy Optimization Directions
- Dynamic Stop-Loss Optimization: Recommend replacing fixed stop-loss with ATR-based dynamic stop-loss for better market adaptation.
- Market Environment Filtering: Add volatility indicators (e.g., VIX) as market environment filters to adjust parameters or pause trading during high volatility.
- Volume-Price Relationship Integration: Consider incorporating volume indicators into signal confirmation system.
- Parameter Adaptation Optimization: Develop parameter adaptation mechanism based on market conditions.
- 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.
Source Pine Script
/*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)
Published by ChaoZhang on the FMZ strategy square · last modified 2024-12-11. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/MACD-Supertrend-Dual-Confirmation-Trend-Following-Trading-Strategy.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- Multi Indicator Dynamic Trend Following Strategy Based on EMA and SMAPine Script · Trend following · 1d
- Supertrend Advance StrategyPine Script · Trend following · 5m
- Supertrend and Moving Average Crossover StrategyPine Script · Trend following · 2h
- Advanced Quantitative Trading Strategy Multi Dimensional Super Trend ATR Dynamic Tracking SystemPine Script · Trend following · 1h
- Dual EMA Crossover Trend Following Strategy with ATR and ADX FiltersPine Script · Trend following · 1d
- Dual SuperTrend with MACD Combination Trading StrategyPine Script · Trend following · 30m