Strategy Overview
This strategy is a trend-following pullback trading system based on a dual moving average framework, combined with adaptive ATR stop-loss and optimized profit-taking ratio design. The core of the strategy is to identify the main trend direction, then enter trades when the price pulls back and reverses, while employing a risk management method based on market volatility. The strategy determines market trends through the positional relationship between fast and slow moving averages, waits for pullback opportunities after confirming the trend, and generates trading signals when the price recovers from the pullback and crosses the fast moving average. The strategy implements a carefully designed risk management module that uses the ATR indicator to dynamically adjust stop-loss positions and employs a 1:2 risk-reward ratio to set profit targets.
Strategy Principles
This strategy is built on the following core principles:
Trend Identification Mechanism: Uses a dual moving average system consisting of a 10-period EMA (fast line) and a 50-period EMA (slow line). When the fast line is above the slow line, an uptrend is identified; when the fast line is below the slow line, a downtrend is identified.
Pullback Confirmation Logic: In an uptrend, when the closing price falls below the fast moving average but the low remains above the slow moving average, it is considered a potential buying pullback; in a downtrend, when the closing price rises above the fast moving average but the high remains below the slow moving average, it is considered a potential selling rally.
Entry Signal Generation:
- Long entry: In an uptrend, a pullback occurs in the previous period, and the current period opens below the fast line but closes above it, forming an upward breakout
- Short entry: In a downtrend, a rally occurs in the previous period, and the current period opens above the fast line but closes below it, forming a downward breakout
Risk Management System:
- Stop-loss setting: Based on the ATR value (14-period) multiplied by an adjustable factor (default 2.0)
- Profit target: Uses a 1:2 risk-reward ratio, with the profit target set at twice the stop-loss distance
This strategy implements a mechanism for finding high-probability entry points during trending markets by waiting for price pullbacks near the moving averages, then entering when signals of pullback completion appear, maximizing the advantages of trend following while reducing entry costs.
Strategy Advantages
Combination of Trend Confirmation and Pullback: The strategy not only follows the main trend direction but also waits for pullbacks to lower entry points, improving the risk-reward ratio. Compared to simple trend-following strategies, this approach avoids entering near trend tops or bottoms, reducing counter-trend risk.
Adaptive Risk Management: By dynamically adjusting stop-loss levels using the ATR indicator, the strategy can adapt its risk exposure according to current market volatility. This means automatically widening stop-loss distances when volatility increases and narrowing them when volatility decreases, effectively preventing being shaken out by market noise.
Clear Entry and Exit Rules: The strategy has explicit entry conditions and exit rules, reducing subjective judgment and emotional interference. The crossover between the fast line and closing price provides clear signals, making strategy execution simpler and more direct.
Optimized Risk-Reward Ratio: By setting profit targets at twice the stop-loss distance, the strategy ensures a favorable risk-reward ratio, maintaining long-term profitability even with a moderate win rate.
Integrated Capital Management: The strategy defaults to using 100% of total funds for trading and considers a 0.01% commission cost, making backtesting results closer to actual trading conditions.
Strategy Risks
Poor Performance in Ranging Markets: In oscillating markets without clear trends, the strategy may generate frequent false signals, leading to consecutive stop-losses. When fast and slow moving averages frequently cross, trend judgment accuracy decreases. It is recommended to pause strategy operation until a clear trend forms.
Parameter Optimization Risk: The choice of moving average periods (10 and 50) and ATR multiplier (2.0) significantly affects strategy performance. There is a high risk of overfitting historical data. It is recommended to conduct robustness tests under different market conditions and timeframes, and consider using adaptive or dynamic parameters.
Rapid Reversal Risk: In cases of sudden trend reversals, the strategy may not adapt to the new trend in time, causing significant losses. Especially when prices gap beyond the stop-loss range, actual losses may be worse than expected.
Liquidity Risk: In markets with poor liquidity, actual execution prices may differ significantly from backtesting results, particularly when volatility suddenly increases, slippage may cause less-than-ideal execution of stops and targets.
Pullback Identification Limitations: The current pullback identification mechanism is relatively simple, relying only on price relationships with moving averages, and may not identify all effective pullbacks or may misjudge complex price structures.
Methods to mitigate risks include: adding filtering conditions (such as volatility filters), optimizing parameters for different market phases, adding trend strength confirmation indicators, and implementing partial position management rather than full position trading.
Strategy Optimization Directions
- Add Trend Strength Filter: The current strategy only uses moving average crossovers to determine trends. Consider adding trend strength indicators such as ADX or DMI as filtering conditions, executing trades only when strong trends are confirmed to improve signal quality. Optimization code example:
adx = ta.adx(14)
strong_trend = adx > 25
long_entry = long_entry and strong_trend
short_entry = short_entry and strong_trend
Dynamic Risk-Reward Ratio Adjustment: The strategy currently uses a fixed 1:2 risk-reward ratio. This can be dynamically adjusted based on market volatility or trend strength, adopting larger profit targets in strong trends and more conservative settings in weak trends.
Add Multiple Timeframe Analysis: Use trend judgments from larger timeframes as filtering conditions to ensure trade direction aligns with the larger cycle trend, reducing counter-trend trading. This can be implemented by introducing moving average data from larger timeframes.
Optimize Pullback Identification Mechanism: The current pullback identification is relatively simple. Consider adding momentum indicators (such as RSI or stochastic oscillators) to assist in judging pullback completion timing, or use support/resistance levels as additional references.
Implement Partial Position Management: Adjust the funding ratio for each trade based on signal strength, market volatility, or trend strength, rather than always using 100% funds. This helps diversify risk and optimize capital efficiency.
Introduce Time Filters: Avoid trading before and after market open, close, or important news releases to reduce risks from abnormal fluctuations. This can be implemented by filtering signals with time conditions.
Add Profit Protection Mechanism: Implement moving stop-loss or protect partial profits after reaching specific profit targets to improve overall risk management effectiveness.
Summary
The "Dual-MA Trend Pullback Trading Strategy with Adaptive ATR-Based Risk Management" is a complete trading system combining the advantages of trend following and pullback entry. The strategy determines trend direction through fast and slow moving averages, waits for price pullbacks near the moving averages, enters when signs of pullback completion appear, and applies an ATR-based dynamic risk management mechanism to ensure controllable risk for each trade.
The main advantages of the strategy lie in low-cost entry, adaptive risk control, and clear trading rules, making it suitable for application in markets with clear trends. However, performance may be poor in oscillating markets, requiring additional filtering mechanisms to improve signal quality.
Future optimization directions include adding trend strength filtering, dynamically adjusting risk-reward ratios, multi-timeframe analysis, and improving pullback identification mechanisms. Through these optimizations, the strategy has the potential to maintain robust performance in different market environments and improve long-term profitability.
This strategy integrates multiple key concepts in technical analysis and provides valuable reference for traders who understand trend following, pullback trading, and risk management. It provides an extensible framework that can be further customized and optimized according to individual trading styles and target market characteristics.
Strategy source code
/*backtest
start: 2024-03-02 00:00:00
end: 2024-04-02 19:00:00
period: 2h
basePeriod: 2h
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT"}]
*/
//@version=5
// Pullback Strategy
strategy("Pullback Strategy", overlay=true, initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.01)
// Inputs
i_fast_ma_length = input.int(10, "Fast MA Length", minval=1)
i_slow_ma_length = input.int(50, "Slow MA Length", minval=1)
i_atr_period = input.int(14, "ATR Period", minval=1)
i_sl_multiplier = input.float(2.0, "Stop Loss Multiplier", minval=0.1, step=0.1)
// Moving Averages
fast_ma = ta.ema(close, i_fast_ma_length)
slow_ma = ta.ema(close, i_slow_ma_length)
// Trend Determination
trend_up = fast_ma > slow_ma
trend_down = fast_ma < slow_ma
// ATR Calculation
atr = ta.atr(i_atr_period)
// Pullback in Progress for Long
pullback_in_progress = trend_up and close < fast_ma and low > slow_ma
// Long Entry Condition
long_entry = trend_up and pullback_in_progress[1] and open < fast_ma and close > fast_ma
// Rally in Progress for Short
rally_in_progress = trend_down and close > fast_ma and high < slow_ma
// Short Entry Condition
short_entry = trend_down and rally_in_progress[1] and open > fast_ma and close < fast_ma
// Long Entry and Exit
if long_entry
entry_price = close
stop_loss_price = entry_price - (atr * i_sl_multiplier)
take_profit_price = entry_price + (2 * (entry_price - stop_loss_price))
strategy.entry("Long", strategy.long)
strategy.exit("Long Exit", "Long", stop=stop_loss_price, limit=take_profit_price)
// Short Entry and Exit
if short_entry
entry_price = close
stop_loss_price = entry_price + (atr * i_sl_multiplier)
take_profit_price = entry_price - (2 * (stop_loss_price - entry_price))
strategy.entry("Short", strategy.short)
strategy.exit("Short Exit", "Short", stop=stop_loss_price, limit=take_profit_price)
// Plotting MAs
plot(fast_ma, color=color.orange, linewidth=2, title="Fast MA")
plot(slow_ma, color=color.red, linewidth=2, title="Slow MA")
// Plotting Entry Points
plotshape(long_entry, title="Long Entry", style=shape.triangleup, color=color.green, location=location.belowbar)
plotshape(short_entry, title="Short Entry", style=shape.triangledown, color=color.red, location=location.abovebar)
Strategy Parameters
The original address: Dual-MA Trend Pullback Trading Strategy with Adaptive ATR-Based Risk Management