Dynamic Supertrend MA Cross Quantitative Trading Strategy

MA ATR supertrend risk management R:R RATIO
Created on: 2025-04-28 13:42:10 Modified on: 2025-04-28 13:42:10
Copy: 0 Number of hits: 363
avatar of ianzeng123 ianzeng123
2
Follow
319
Followers

 Dynamic Supertrend MA Cross Quantitative Trading Strategy  Dynamic Supertrend MA Cross Quantitative Trading Strategy

Overview

The Dynamic Supertrend MA Cross Quantitative Trading Strategy is a trading system that combines the Supertrend indicator with Moving Average (MA) crossovers, primarily designed for forex market trading on 1-hour to 4-hour timeframes. The strategy utilizes price crossovers with a moving average as the initial signal, then confirms the trend direction using the Supertrend indicator, creating a complete entry, stop-loss, and take-profit system. The core strength of this strategy lies in capturing trend reversal points while implementing automated risk management through a predefined risk-to-reward ratio.

Strategy Principles

The core principle of this strategy is based on a multiple-confirmation trend following system, including the following key components:

  1. Moving Average Crossover Signal: The strategy employs a 20-period (adjustable between 10-50) Simple Moving Average (SMA) as a baseline. When price crosses this moving average, it’s considered a potential trend change signal. The system supports two crossing modes: close price crossover (more conservative) or high/low point crossover (more aggressive).

  2. Supertrend Confirmation: A Supertrend indicator with a factor of 2.8 (adjustable between 2.0-3.5) and a 10-period lookback (adjustable between 5-20) serves as the trend direction confirmation tool. The Supertrend indicator shows green for uptrends and red for downtrends.

  3. Entry Logic:

    • Long condition: Price crosses above the moving average AND the Supertrend indicator shows an uptrend (green)
    • Short condition: Price crosses below the moving average AND the Supertrend indicator shows a downtrend (red)
  4. Risk Management System:

    • Stop-loss: Set at 1.8 times the ATR value
    • Take-profit: Based on a preset risk-to-reward ratio (default 3.0), meaning 3 times the stop-loss distance
    • Position sizing: 15% of account equity per trade

Strategy Advantages

  1. Multiple Confirmation Mechanism: By combining moving average and Supertrend indicator confirmations, the strategy effectively reduces false signals and improves trading accuracy. In clearly trending markets, this dual confirmation effectively filters out misleading signals that occur during choppy market conditions.

  2. Strong Adaptability: The strategy parameters offer high adjustability, including moving average period, Supertrend multiplier, and ATR period. This allows the strategy to be optimized for different market environments and volatility conditions. The 2.5-3.2 adjustment range for the Supertrend multiplier is particularly useful for adapting to markets with varying volatility.

  3. Comprehensive Risk Management: The built-in ATR-based dynamic stop-loss and take-profit system ensures that the risk for each trade is controlled within a predetermined range. The fixed risk-to-reward ratio (3:1) contributes to long-term profitability potential.

  4. Volatility Adaptation: The strategy automatically adjusts stop-loss and profit targets through the ATR indicator, allowing it to adapt to changes in market volatility. It sets wider stops in highly volatile markets and tightens them in less volatile conditions.

  5. Moderate Trading Frequency: Due to the multiple confirmation mechanism, the strategy doesn’t trade excessively, reducing transaction costs and overtrading risk.

Strategy Risks

  1. Delayed Trend Reversal Identification: As a trend-following strategy, there may be a delay in identifying trend reversals at their early stages, resulting in less than ideal entry points. A solution is to consider adding more sensitive early signal indicators as auxiliary tools.

  2. Poor Performance in Ranging Markets: In sideways markets with no clear trend, the strategy may generate consecutive losing trades. It’s advisable to pause the strategy or switch to an alternative parameter set specifically designed for ranging markets when such conditions are identified.

  3. Parameter Sensitivity: Small changes in the Supertrend multiplier can significantly impact strategy performance. Backtesting is necessary to determine the most suitable parameter settings for specific trading instruments and timeframes.

  4. False Breakout Risk: Situations where price briefly crosses the moving average and immediately reverses can trigger false signals. Consider adding a confirmation period or price momentum confirmation to reduce losses from false breakouts.

  5. Market Environment Dependency: The strategy performs better during London and New York trading sessions and may underperform during Asian sessions with lower liquidity. Consider adjusting parameters based on trading sessions or selectively enabling the strategy during specific periods.

Strategy Optimization Directions

  1. Introduction of Time Filters: The code can be optimized to include trading session filters, executing trades only during active London and New York trading hours. This can be implemented by adding time condition logic to avoid low-liquidity market environments.

  2. Dynamic Supertrend Factor Adjustment: The strategy currently uses a fixed Supertrend multiplier, which could be improved to automatically adjust based on market volatility. For example, using higher multiplier values (3.0-3.2) during high volatility periods and lower values (2.5-2.7) during low volatility periods.

  3. Crossover Confirmation Mechanism Optimization: Consider adding a mechanism requiring price to maintain position above/below the moving average for a certain period or distance to reduce false breakouts. This could require price to maintain consistent direction for N periods after crossing.

  4. Integration of Market Structure Analysis: Introduce support/resistance levels or price structure analysis to improve entry quality. Consider only taking crossover signals that occur near major support/resistance levels.

  5. Adaptive Risk Management: The current risk-to-reward ratio is fixed but could be optimized to dynamically adjust based on market conditions. For example, increasing the ratio in strong trending markets and decreasing it in weaker trends.

  6. Multi-timeframe Analysis: Introduce higher timeframe trend confirmation, for example, only executing signals on lower timeframes when they align with the daily trend direction. This would require adding multi-timeframe analysis functionality.

Summary

The Dynamic Supertrend MA Cross Quantitative Trading Strategy builds a relatively robust trend following system by combining moving average crossover signals with Supertrend indicator confirmation. The strategy is particularly suitable for application on 1-4 hour charts of major currency pairs such as EUR/USD and GBP/USD, and performs best during London and New York trading sessions.

The core advantages of the strategy lie in its multiple confirmation mechanism and comprehensive risk management system, providing a systematic framework for trading through preset risk-to-reward ratios and volatility-based stop-loss settings. However, as a trend-following system, it may underperform in ranging markets and carries the inherent risk of delayed trend reversal identification.

By implementing the suggested optimization directions, particularly introducing time filters, dynamic parameter adjustments, and multi-timeframe analysis, the robustness and adaptability of the strategy can be further enhanced. Ultimately, this strategy provides quantitative traders with a reliable base framework that can be customized and extended according to individual risk preferences and market conditions.

Strategy source code
/*backtest
start: 2025-01-01 00:00:00
end: 2025-04-26 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT"}]
*/

//@version=5
strategy("Islamabad Forex Academy Strategy-1", 
     overlay=true,
     margin_long=100,
     margin_short=100,
     initial_capital=10000,
     default_qty_type=strategy.percent_of_equity,
     default_qty_value=15,
     commission_type=strategy.commission.percent,
     commission_value=0.03,
     pyramiding=0)

// ===== CORE PARAMETERS =====
maLength = input.int(20, "Moving Average Length", minval=10, maxval=50)
atrPeriod = input.int(10, "ATR Period", minval=5, maxval=20)
supertrendFactor = input.float(2.8, "Supertrend Multiplier", step=0.1, minval=2.0, maxval=3.5)
rrRatio = input.float(3.0, "Risk:Reward Ratio", minval=2.0, maxval=5.0)
useCloseFilter = input.bool(true, "Require Close Cross MA")

// ===== CALCULATIONS =====
// Single Moving Average
ma = ta.sma(close, maLength)

// Supertrend with tighter settings
[supertrendLine, supertrendDir] = ta.supertrend(supertrendFactor, atrPeriod)

// Trend Conditions
uptrend = supertrendDir < 0  // Supertrend green
downtrend = supertrendDir > 0 // Supertrend red

// Entry Logic - Price must cross MA and stay beyond it
maCrossUp = useCloseFilter ? ta.crossover(close, ma) : ta.crossover(high, ma)
maCrossDown = useCloseFilter ? ta.crossunder(close, ma) : ta.crossunder(low, ma)

// Confirm with Supertrend
longCondition = maCrossUp and uptrend
shortCondition = maCrossDown and downtrend

// ===== RISK MANAGEMENT =====
atrValue = ta.atr(atrPeriod)
stopDistance = atrValue * 1.8
profitDistance = stopDistance * rrRatio

// ===== EXECUTION =====
if (longCondition)
    strategy.entry("Long", strategy.long)
    strategy.exit("Exit Long", "Long", 
         stop=close - stopDistance, 
         limit=close + profitDistance,
         when=strategy.position_size > 0)

if (shortCondition)
    strategy.entry("Short", strategy.short)
    strategy.exit("Exit Short", "Short", 
         stop=close + stopDistance, 
         limit=close - profitDistance,
         when=strategy.position_size < 0)

// ===== VISUALS =====
// MA Plot
plot(ma, "20 MA", color=color.new(#FF6D00, 0), linewidth=2)

// Supertrend Plot
uPlot = plot(uptrend ? supertrendLine : na, "Up Trend", color=color.new(#00C805, 0), linewidth=2)
dPlot = plot(downtrend ? supertrendLine : na, "Down Trend", color=color.new(#FF1100, 0), linewidth=2)
fill(uPlot, dPlot, color=color.new(supertrendDir < 0 ? #00C805 : #FF1100, 90))

// Entry Signals
plotshape(longCondition, "Buy", shape.triangleup, location.belowbar, color=color.new(#00C805, 0), size=size.small)
plotshape(shortCondition, "Sell", shape.triangledown, location.abovebar, color=color.new(#FF1100, 0), size=size.small)