Multi-Dimensional Technical Indicator Fusion Trend Following Quantitative Strategy

EMA RSI MACD ATR SMA
Created on: 2025-05-26 14:19:14 Modified on: 2025-05-26 14:19:14
Copy: 1 Number of hits: 569
avatar of ianzeng123 ianzeng123
2
Follow
319
Followers

 Multi-Dimensional Technical Indicator Fusion Trend Following Quantitative Strategy  Multi-Dimensional Technical Indicator Fusion Trend Following Quantitative Strategy

Overview

The Multi-Indicator Trend-Following Momentum Confirmation Trading System is a quantitative trading strategy developed using Pine Script v6 language on the TradingView platform. This strategy integrates multiple technical indicators, including Exponential Moving Averages (EMA), Relative Strength Index (RSI), and Moving Average Convergence Divergence (MACD), combined with volume and volatility filters to create a comprehensive and systematic trading decision framework. The strategy aims to capture market trend reversal points while enhancing signal reliability through multi-indicator confirmation, ultimately generating high-quality buy and sell signals. The strategy also incorporates dynamic stop-loss and take-profit settings based on Average True Range (ATR), effectively managing the risk-reward ratio for each trade.

Strategy Principles

The core principle of this strategy is to identify trend change points through multi-indicator crossovers and condition confirmations, achieving trend following and momentum confirmation. The specific implementation logic is as follows:

  1. Moving Average System: The strategy uses two Exponential Moving Averages (EMAs), a fast EMA (default 10 periods) and a slow EMA (default 20 periods). When the fast EMA crosses above the slow EMA, it generates a potential buy signal; when the fast EMA crosses below the slow EMA, it generates a potential sell signal.

  2. RSI Filter: To confirm the validity of moving average crossover signals, the strategy incorporates the RSI indicator (default 14 periods). For buy conditions, RSI must be greater than 50, indicating upward momentum; for sell conditions, RSI must be less than 50, indicating downward momentum.

  3. Volume Confirmation: The strategy requires that the volume at signal generation must be higher than a specific multiple (default 1.5 times) of the volume moving average (default 20 periods), ensuring that trades occur with sufficient market participation, avoiding false breakouts.

  4. Risk Management Mechanism: The strategy uses the ATR indicator (default 14 periods) to dynamically set stop-loss and take-profit levels. For buy trades, the stop-loss is set at the entry price minus 2 times the ATR value, and the take-profit is set at the entry price plus 3 times the ATR value; for sell trades, it’s the opposite. This method ensures that stop-loss and take-profit levels automatically adjust according to market volatility.

The strategy execution flow: first calculating the current values of various technical indicators, then evaluating whether multiple condition combinations meet entry criteria, issuing trading signals when conditions are met, and setting corresponding stop-loss and take-profit levels.

Strategy Advantages

Analyzing the code implementation of this strategy, the following main advantages can be summarized:

  1. Multi-dimensional Signal Confirmation: By combining moving average crossovers, RSI momentum, and volume filtering, the strategy can effectively reduce false signals and improve the quality and reliability of trading signals. This multi-layered confirmation mechanism ensures that the strategy only triggers trades in situations with higher probability of success.

  2. Adaptive Risk Management: The strategy adopts an ATR-based dynamic stop-loss and take-profit mechanism, which can automatically adjust risk parameters according to actual market volatility. It sets wider stops in more volatile markets and narrower stops in less volatile markets, achieving intelligent risk management.

  3. Flexible Parameterized Design: All key parameters of the strategy are exposed through the input interface, allowing traders to adjust based on different market environments and personal risk preferences. This design gives the strategy high adaptability and customizability.

  4. Precise Capital Management: The strategy sets position size through percentage_of_equity, ensuring that each trade uses a fixed percentage of account equity (default 90%), implementing systematic capital management.

  5. Intuitive Visual Feedback: The strategy clearly marks buy and sell signals on the chart and displays specific entry prices, allowing traders to visually track the strategy’s performance and decision-making process.

  6. Leveraging Pine Script v6 Features: The strategy fully utilizes the advanced features of Pine Script v6, such as improved dynamic data handling capabilities, making the code more concise and efficient.

Strategy Risks

Despite its multiple advantages, this strategy also has some potential risks and limitations:

  1. Trend Change Lag: Since the strategy is based on moving average crossovers, it may only provide signals after a trend has already changed significantly, leading to less than ideal entry points. This is a common drawback of all trend-following strategies.

  2. Poor Performance in Ranging Markets: In sideways or trendless market environments, moving averages may frequently cross, generating numerous false signals and resulting in consecutive losses for the strategy.

  3. Over-reliance on Technical Indicators: The strategy is entirely based on technical indicators without considering fundamental factors or market structure. Pure technical indicators may fail during major news events or structural market changes.

  4. Fixed Risk Multipliers: Although the strategy uses ATR to dynamically set stop-loss and take-profit levels, the ATR multipliers are fixed (2x ATR for stop-loss, 3x ATR for take-profit). This may not be suitable for all market environments, especially in different volatility cycles.

  5. Impact of Volume Anomalies: The strategy relies on volume confirmation, but in cases of abnormal volume fluctuations or interference, it may incorrectly trigger or miss trading signals.

  6. Parameter Optimization Risk: While parameterized design provides flexibility, it also brings the risk of over-optimization (curve-fitting). Excessive optimization may cause the strategy to perform well on historical data but poorly in future live markets.

Strategy Optimization Directions

Based on an in-depth analysis of the strategy code, here are several possible optimization directions:

  1. Add Market Environment Filter: Introduce a market environment recognition mechanism, such as using ADX (Average Directional Index) to determine if the market is in a trending state, or using Bollinger Band width to assess market volatility. In non-trending market environments, position size can be automatically reduced or trading paused to reduce losses in ranging markets.

  2. Optimize Signal Confirmation Logic: Consider integrating the MACD indicator more deeply into entry conditions, for example, requiring the MACD line to be above (for buys) or below (for sells) the signal line, adding another layer of confirmation. Currently, although MACD values are calculated in the code, they are not used in trading conditions.

  3. Dynamically Adjust ATR Multipliers: Adjust stop-loss and take-profit ATR multipliers dynamically based on market volatility levels, for example, using larger multipliers in high-volatility environments and smaller multipliers in low-volatility environments, to adapt to different market states.

  4. Add Time Filtering: Introduce trading time window restrictions to avoid trading during specific high-volatility or low-liquidity time periods, such as before and after important economic data releases or market opening/closing periods.

  5. Implement Partial Take-Profit Strategy: Modify the take-profit logic to implement batch profit-taking, for example, closing half the position when reaching 1.5 times ATR and closing the remaining position at 3 times ATR. This can extend profit space while maintaining a high win rate.

  6. Add Trend Strength Assessment: In addition to trend direction, assess trend strength, for example, using the slope of moving averages or the rate of change of RSI, only entering when the trend is strong enough.

  7. Optimize Position Management: Implement volatility-based dynamic position management, increasing positions in low-volatility environments and reducing positions in high-volatility environments, to balance risk and reward.

Summary

The Multi-Indicator Trend-Following Momentum Confirmation Trading System is a well-structured, logically clear quantitative trading strategy that builds a relatively reliable trading decision framework by comprehensively utilizing multiple technical indicators and filtering conditions. The core advantages of the strategy lie in its multi-layered signal confirmation mechanism and adaptive risk management system, enabling it to effectively capture trend reversal points in clearly trending markets while effectively controlling risk.

However, as a trend-following strategy, its performance may be limited in ranging markets, and it has the inherent drawback of signal lag. By introducing market environment filtering, optimizing signal confirmation logic, implementing dynamic risk management, and other improvement measures, the robustness and adaptability of the strategy can be further enhanced.

For traders, understanding the principles and limitations of the strategy is crucial. This strategy is most suitable for application in market environments with clear trends and should be used in conjunction with broader market analysis and risk management principles. At the same time, traders should avoid excessive parameter optimization and instead focus on the overall stability of the strategy’s performance across different market environments. With reasonable parameter settings and necessary optimization adjustments, this strategy can become a powerful weapon in a trader’s technical analysis toolkit.

Strategy source code
/*backtest
start: 2024-05-26 00:00:00
end: 2025-05-25 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"SOL_USDT"}]
*/

//@version=6
strategy(title="Multi-Indicator Trend-Following Strategy v6",
     shorttitle="MITF v6",
     overlay=true,
     initial_capital=100000,
     default_qty_type=strategy.percent_of_equity,
     default_qty_value=90,
     commission_type=strategy.commission.cash_per_order,
     commission_value=1.0,
     margin_long=100,
     margin_short=100,
     pyramiding=1)

// --- Strategy Inputs ---
// Moving Averages
fastMALengthInput = input.int(10, title="Fast MA Length", minval=1)
slowMALengthInput = input.int(20, title="Slow MA Length", minval=1)

// RSI
rsiLengthInput = input.int(14, title="RSI Length", minval=1)
rsiOversoldInput = input.int(30, title="RSI Oversold Level", minval=0, maxval=100)
rsiOverboughtInput = input.int(70, title="RSI Overbought Level", minval=0, maxval=100)

// MACD
fastMACDLengthInput = input.int(12, title="MACD Fast Length", minval=1)
slowMACDLengthInput = input.int(26, title="MACD Slow Length", minval=1)
signalMACDLengthInput = input.int(9, title="MACD Signal Length", minval=1)

// Volume Filter
volumeMALengthInput = input.int(20, title="Volume MA Length", minval=1)
volumeMultiplierInput = input.float(1.5, title="Volume Confirmation Multiplier", minval=0.1)

// ATR for Stop Loss / Take Profit
atrPeriodInput = input.int(14, title="ATR Period", minval=1)
stopLossATRMultiInput = input.float(2.0, title="Stop Loss ATR Multiplier", minval=0.1)
takeProfitATRMultiInput = input.float(3.0, title="Take Profit ATR Multiplier", minval=0.1)

// --- Indicator Calculations ---
fastMA = ta.ema(close, fastMALengthInput)
slowMA = ta.ema(close, slowMALengthInput)
rsiValue = ta.rsi(close, rsiLengthInput)
[macdLine, signalLine, _] = ta.macd(close, fastMACDLengthInput, slowMACDLengthInput, signalMACDLengthInput)
volumeMA = ta.sma(volume, volumeMALengthInput)
atrValue = ta.atr(atrPeriodInput)

// --- Entry Conditions ---
longCondition = ta.crossover(fastMA, slowMA) and rsiValue > 50 and volume > (volumeMA * volumeMultiplierInput)
shortCondition = ta.crossunder(fastMA, slowMA) and rsiValue < 50 and volume > (volumeMA * volumeMultiplierInput)

// --- Order Execution ---
if longCondition
    strategy.entry("Long", strategy.long)

if shortCondition
    strategy.entry("Short", strategy.short)

longStopPrice = strategy.position_avg_price - (atrValue * stopLossATRMultiInput)
longTakeProfitPrice = strategy.position_avg_price + (atrValue * takeProfitATRMultiInput)
shortStopPrice = strategy.position_avg_price + (atrValue * stopLossATRMultiInput)
shortTakeProfitPrice = strategy.position_avg_price - (atrValue * takeProfitATRMultiInput)

if strategy.position_size > 0
    strategy.exit(id="Exit Long", from_entry="Long", stop=longStopPrice, limit=longTakeProfitPrice)

if strategy.position_size < 0
    strategy.exit(id="Exit Short", from_entry="Short", stop=shortStopPrice, limit=shortTakeProfitPrice)

// --- Plots ---
plot(fastMA, title="Fast MA", color=color.blue, linewidth=2)
plot(slowMA, title="Slow MA", color=color.orange, linewidth=2)

plotshape(longCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(shortCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)


// --- Alerts ---
alertcondition(longCondition, title="Buy Alert", message="BUY signal on {{ticker}} at {{close}}")
alertcondition(shortCondition, title="Sell Alert", message="SELL signal on {{ticker}} at {{close}}")