Enhanced Price Volume Trend Momentum Strategy
This strategy is a trading system based on MACD indicator and price-volume relationship, which identifies market trend reversal points by observing changes in MACD histogram patterns. The strategy employs a dynamic…

Overview
This strategy is a trading system based on MACD indicator and price-volume relationship, which identifies market trend reversal points by observing changes in MACD histogram patterns. The strategy employs a dynamic profit-taking and stop-loss mechanism using the ATR indicator to adapt to market volatility and effectively control risk.
Strategy Principle
The core logic of the strategy is built on the color changes of MACD histogram, combined with dual EMA and SMA moving average systems. When the MACD histogram transitions from dark to light color, it indicates a momentum shift, triggering the system to execute trades. Specifically:
- Calculate MACD values using fast(12) and slow(26) moving averages
- Smooth MACD with a 9-period signal line
- Monitor color depth changes in MACD histogram
- Set dynamic profit targets and stop losses using 14-period ATR
Strategy Advantages
- Scientific combination of indicators, with MACD effectively capturing trends and ATR adapting to volatility
- Flexible profit-taking and stop-loss settings adjustable through multiplier parameters for different market characteristics
- Clear trading signals with intuitive entry timing based on histogram color changes
- Accommodates both long and short trading, increasing strategy versatility and profit opportunities
Strategy Risks
- MACD as a lagging indicator may miss optimal entry points in rapid market movements
- May generate false signals in ranging markets, leading to frequent trading
- Improper ATR multiplier settings can result in stops being too loose or too tight
- Requires proper money management to avoid excessive single-trade losses
Strategy Optimization Directions
- Incorporate volume confirmation signals to improve signal reliability
- Add trend filters to reduce false signals in ranging markets
- Optimize profit-taking and stop-loss multipliers with dynamic adjustment based on different timeframes
- Include volatility filtering to reduce trading frequency during highly volatile periods
- Consider implementing time filters to avoid trading during unfavorable periods
Summary
This is a comprehensive strategy combining classic technical analysis indicator MACD with modern risk control methods. It captures market momentum shifts by observing MACD histogram pattern changes while using ATR for dynamic risk control. The strategy is well-designed with clear operational logic and practical value. Through continuous optimization and improvement, this strategy shows promise for better performance in real trading conditions.
Source Pine Script
/*backtest
start: 2019-12-23 08:00:00
end: 2025-01-08 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":49999}]
*/
//@version=5
strategy(title="Xuan cut MACD short of empty energy capacity strategy", shorttitle="Xuan cut MACD short of short energy capacity strategy", overlay=true)
//=== 1) Parameter ===//
fast_length = input.int(title="Fast Length", defval=12)
slow_length = input.int(title="Slow Length", defval=26)
src = input.source(title="MACD Source", defval=close)
signal_length = input.int(title="Signal Smoothing", defval=9, minval=1, maxval=50)
sma_source = input.string(title="Oscillator MA Type", defval="EMA", options=["SMA","EMA"])
sma_signal = input.string(title="Signal MA Type", defval="EMA", options=["SMA","EMA"])
// Enable multiple orders / Empty order
useLong = input.bool(title="Enable multiple orders?(Bottom red)", defval=true)
useShort = input.bool(title="Enable short orders?(Top green)", defval=true)
// Take profit multiple (1~10times ATR)
tpATRmult = input.int(title="take profit ATR multiple (1~10)", defval=10, minval=1, maxval=500)
// Stop loss multiple (1~10times ATR)
slATRmult = input.int(title="Stop loss ATR multiple (1~10)", defval=3, minval=1, maxval=500)
//=== 2) MACD Calculate ===//
fast_ma = sma_source == "SMA" ? ta.sma(src, fast_length) : ta.ema(src, fast_length)
slow_ma = sma_source == "SMA" ? ta.sma(src, slow_length) : ta.ema(src, slow_length)
macd = fast_ma - slow_ma
signal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length)
hist = macd - signal
//=== 3) Determine dark color/Light Color (Used for Change Signals))===//
darkGreen = hist >= 0 and hist <= hist[1] // Above, the bars shrink or remain flat
lightGreen = hist >= 0 and hist > hist[1] // Above, bars become larger
darkRed = hist < 0 and hist <= hist[1] // Below, the bars (absolute value) increase or stay the same
lightRed = hist < 0 and hist > hist[1] // Below, the bars (absolute value) shrink
// By "Deep → Did 'shallow' occur in the previous one
colorChangeToLightGreen = darkGreen[1] and lightGreen
colorChangeToLightRed = darkRed[1] and lightRed
//=== 4) ATR Calculate (Used for take profit and stop loss) ===//
atrPeriod = 14
atrValue = ta.atr(atrPeriod)
//=== 5) Long position strategy: dark red → Light Red (Bottom red) ===//
if useLong and colorChangeToLightRed
// With Current K Line low - ATRMultiplier as Stop Loss for Long Position
longStopLoss = low - (slATRmult * atrValue)
// With Current close + ATRMultiplier as Take Profit for Long Position
longTakeProfit = close + (tpATRmult * atrValue)
// Enter Long
strategy.entry("Long Entry", strategy.long, comment="Many", qty=1)
strategy.exit("close long", "Long Entry", stop=longStopLoss, limit=longTakeProfit)
//=== 6) Short position strategy: dark green → Light Green (Top green) ===//
if useShort and colorChangeToLightGreen
// With Current K Line high + ATRMultiplier as Stop Loss for Short Position
shortStopLoss = high + (slATRmult * atrValue)
// With Current close - ATRMultiplier as Take Profit for Short Position
shortTakeProfit = close - (tpATRmult * atrValue)
// Enter Short
strategy.entry("Short Entry", strategy.short, comment="Empty", qty=1)
strategy.exit("close short", "Short Entry", stop=shortStopLoss, limit=shortTakeProfit)
//=== 7) Draw MACD and histogram ===//
hline(0, "Zero Line", color=color.new(#787B86, 50))
// Bar chart color:
// - Above (hist >= 0) Hour:hist Bigger than the previous one (Light Green) Or Small (Dark Green)
// - Below (hist < 0) Hour:hist Bigger than the previous one (Light Red) Or Small (Dark Red)
plot(hist,title="Histogram",style=plot.style_columns,color = hist >= 0? (hist > hist[1] ? #26A69A : #B2DFDB) : (hist > hist[1] ? #FFCDD2 : #FF5252) )
// Draw MACD And Signal
plot(macd, title="MACD", color=#2962FF)
plot(signal, title="Signal", color=#FF6D00)
Published by ChaoZhang on the FMZ strategy square · last modified 2025-01-10. 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/Enhanced-Price-Volume-Trend-Momentum-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
- KST EMA Momentum Trend Following StrategyPine Script · Momentum · 1d
- Multi Indicator Trend Momentum Trading Strategy with Dynamic Risk Management SystemPine Script · Momentum · 1h
- Multi Trend Momentum Crossover Strategy with Volatility Optimization SystemPine Script · Momentum · 1d
- Multi Indicator Dynamic Stop Loss Momentum Trend Trading StrategyPine Script · Momentum · 1h
- Multi EMA Trend Momentum Trading Strategy with Risk Management SystemPine Script · Momentum · 1h
- Multi Level Technical Indicator Momentum Trading Strategy Based on Enhanced MACD Volume Strength and EMA Signal SystemPine Script · Momentum · 1h