
This quantitative trading strategy, named “Multi-Timeframe Dynamic Trend Detection System,” is a comprehensive system that combines multiple technical indicators, primarily integrating Exponential Moving Average (EMA) crossover, Relative Strength Index (RSI), Volume Weighted Average Price (VWAP), and Average Directional Index (ADX) for trading decisions. The strategy employs multi-timeframe analysis, combining trend confirmation and momentum indicators to effectively identify market overbought and oversold areas while determining institutional capital flow. It is particularly suitable for short-term trend reversal trading and swing operations. The system allows traders to flexibly choose long-only, short-only, or bidirectional trading, while providing an ADX filter option to reduce false signals in oscillating markets. The overall design focuses on both signal quality and operational flexibility.
The core principle of this strategy is built on the collaborative confirmation of multi-level market indicators. First, the system calculates two Exponential Moving Averages (EMAs) of different periods, specifically a short-period EMA(9) and a long-period EMA(21), to identify trend direction and potential trend reversal points. Second, the system obtains RSI(14) data from the 15-minute timeframe, introducing cross-timeframe analysis to confirm price momentum status. Third, the system uses VWAP from the current timeframe as a reference indicator for institutional capital participation and sets a gap threshold (0.1%) between VWAP and EMAs to filter trading signals.
Specifically, short entry conditions must simultaneously satisfy: short-term EMA crossing below long-term EMA (bearish crossover), 15-minute RSI value greater than 30 (non-oversold), and VWAP significantly lower than both EMAs (by at least 0.1%), indicating institutional selling pressure and bearish sentiment. The long entry condition currently only requires the 15-minute RSI to be below 30 (oversold condition), without EMA and VWAP filtering.
Additionally, the strategy introduces an optional ADX filter, manually calculating the ADX value (default length 14) and setting a minimum threshold (default 20) to ensure trading only occurs in clear trends. Users can enable or disable the ADX filter, adding flexibility to the strategy. The strategy also supports selecting trading direction (“Long”, “Short”, or “Both”) through input parameters, making it easier to adapt to automated trading systems such as OKX bots or TradingView alerts.
Multiple Indicator Collaborative Confirmation: By combining EMA crossover, RSI momentum, VWAP institutional capital flow, and ADX trend strength, the strategy forms a multi-layered trade signal confirmation mechanism, significantly improving signal reliability.
Multi-Timeframe Analysis: By incorporating RSI data from the 15-minute timeframe, the strategy can assess market momentum from a more macro perspective, reducing potential blind spots that might arise from single timeframe analysis.
Institutional Capital Perspective: Using the gap between VWAP and EMAs as an indicator of institutional capital participation provides a unique institutional perspective that helps the strategy better identify genuine market pressure and support areas.
Flexible Operation Mode: Through the tradeDirection parameter, users can choose long-only, short-only, or bidirectional trading based on market conditions or personal preference, without maintaining multiple strategy versions.
Dynamic Trend Filtering: The optional ADX filter helps the strategy trade only in clear trends, effectively reducing false signals in oscillating markets while retaining the flexibility to disable this filter.
Integrated Risk Management: The strategy has built-in stop-loss and take-profit mechanisms (fixed price points), combined with RSI overbought/oversold conditions as exit signals, forming a complete trading loop.
High Code Efficiency: The strategy code has a clear structure, modular logic, and efficient calculation process, facilitating maintenance and further optimization.
Incomplete Long Entry Conditions: The current long entry logic is based solely on the RSI<30 oversold condition, lacking EMA crossover and VWAP filtering, which may lead to premature entry or frequent long positions in a sustained downtrend, increasing the risk of losses.
Fixed Stop-Loss and Take-Profit Settings: The strategy uses fixed points (100 points stop-loss, 200 points take-profit) rather than percentage-based or volatility-based dynamic stops, which may not be flexible enough in different volatility environments - too loose during high volatility periods and too tight during low volatility periods.
No Trade Frequency Control: The absence of a strategy.opentrades == 0 condition may lead to repeated entries when signals are triggered consecutively, creating position stacking and inadvertently increasing risk exposure.
ADX Calculation Complexity: Manual calculation of ADX increases code complexity, and while functionally correct, it has poorer maintainability. Calculation deviations could lead to incorrect trend judgments.
Fixed VWAP Gap Threshold: The fixed 0.1% VWAP gap threshold may not be suitable for all market conditions - potentially too loose in high-volatility markets and too strict in low-volatility markets.
Lack of Backtesting Sensitivity Analysis: The code does not show results of parameter optimization or sensitivity analysis, making it impossible to determine whether the current parameter combination (e.g., EMA 9⁄21, RSI 14, ADX 14⁄20) is optimal.
Potential Time Delay: Cross-timeframe data requests (request.security) may introduce data delays in certain situations, especially in rapidly changing markets, affecting the precision of trading timing.
Perfect Long Entry Logic: Add mirrored VWAP conditions and EMA crossover filtering for long strategies, requiring VWAP to be significantly above both EMAs (e.g., 0.1%) and short-term EMA to cross above long-term EMA, making long and short logic symmetrical and improving long signal quality.
Add Trade Frequency Control: Include a strategy.opentrades == 0 condition in entry criteria to prevent position stacking due to consecutive signals, better controlling risk exposure.
Dynamic Stop-Loss and Take-Profit Settings: Dynamically adjust stop-loss and take-profit levels based on Average True Range (ATR), making risk management more adaptable to current market volatility, replacing the current fixed point settings.
Optimize ADX Calculation: Consider using TradingView’s built-in ta.adx() function instead of manual calculation to simplify code and improve maintainability, while adding ADX direction determination (+DI vs -DI relationship) to further refine trend direction.
Dynamic VWAP Gap Threshold: Design the VWAP gap threshold as a dynamic parameter based on market volatility, for example, associated with ATR, allowing filter conditions to self-adapt to different market environments.
Add Trading Time Filtering: Introduce trading session control to avoid low liquidity periods or major news announcement periods, reducing the risks of slippage and unexpected volatility.
Multi-Timeframe Trend Consistency: Consider adding higher timeframe (such as 1-hour or 4-hour) trend direction judgments, trading only when trends across multiple timeframes are consistent, further reducing false signals.
Introduce Volume Confirmation: Add volume indicator confirmation, such as requiring trading volume to be significantly higher than the average of previous periods when EMA crossover occurs, improving the reliability of trend change signals.
The “Multi-Timeframe Dynamic Trend Detection System” is a comprehensive quantitative strategy combining multiple technical analysis tools. Through multiple confirmation mechanisms including EMA crossover, RSI momentum, VWAP institutional capital flow, and ADX trend strength, it provides traders with relatively reliable entry and exit signals. The strategy particularly emphasizes the combined analysis of institutional capital behavior and retail sentiment, incorporating both trend-following and reversal trading characteristics.
While the strategy excels in multi-indicator collaboration and flexibility, issues remain such as incomplete long conditions, fixed risk management, and potential repeated entries. Through perfecting long logic, implementing dynamic risk management, adding trade frequency control, optimizing ADX calculation, designing dynamic VWAP thresholds, introducing trading time filtering, and requiring multi-timeframe consistency, the strategy’s performance and stability can be significantly improved.
Overall, this strategy represents a comprehensive and flexible trading system design approach. By comprehensively considering technical indicators, price structure, market sentiment, and institutional behavior, it provides traders with a tool that can theoretically adapt to various market environments. With the suggested optimizations, this strategy has the potential to become a more complete and efficient trading system.
/*backtest
start: 2024-05-13 00:00:00
end: 2025-05-11 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("MinhPhan MA Crossover Strategy RSI 15m + ADX Toggle", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.001)
// === Inputs ===
shortLen = input.int(9, title="Short EMA")
longLen = input.int(21, title="Long EMA")
useAdxFilter = input.bool(true, title="Enable ADX Filter?")
adxLen = input.int(14, title="ADX Length")
adxThresh = input.float(20, title="Min ADX to Trade")
// === EMAs ===
shortMA = ta.ema(close, shortLen)
longMA = ta.ema(close, longLen)
// === VWAP ===
vwap = ta.vwap
// === RSI from 15-minute timeframe ===
rsi_15m = request.security(syminfo.tickerid, "15", ta.rsi(close, 14))
// === Manual ADX Calculation ===
upMove = high - high[1]
downMove = low[1] - low
plusDM = na(upMove) or upMove <= downMove or upMove < 0 ? 0 : upMove
minusDM = na(downMove) or downMove <= upMove or downMove < 0 ? 0 : downMove
tr = math.max(math.max(high - low, math.abs(high - close[1])), math.abs(low - close[1]))
smoothedTR = ta.rma(tr, adxLen)
smoothedPlusDM = ta.rma(plusDM, adxLen)
smoothedMinusDM = ta.rma(minusDM, adxLen)
plusDI = 100 * smoothedPlusDM / smoothedTR
minusDI = 100 * smoothedMinusDM / smoothedTR
dx = 100 * math.abs(plusDI - minusDI) / (plusDI + minusDI)
adx = ta.rma(dx, adxLen)
isTrending = useAdxFilter ? adx > adxThresh : true // ADX toggle logic
// === VWAP Gap Filter ===
gapThreshold = 0.001
vwapBelowEMAs =
(shortMA - vwap) / shortMA > gapThreshold and
(longMA - vwap) / longMA > gapThreshold
// === Direction Control ===
tradeDirection = input.string(title="Trade Direction", defval="Both", options=["Long", "Short", "Both"])
allowLong = tradeDirection == "Long" or tradeDirection == "Both"
allowShort = tradeDirection == "Short" or tradeDirection == "Both"
// === Entry Conditions ===
if (allowLong and rsi_15m < 30 and isTrending)
strategy.entry("Long", strategy.long)
if (allowShort and rsi_15m > 30 and ta.crossunder(shortMA, longMA) and vwapBelowEMAs and isTrending)
strategy.entry("Short", strategy.short)
// === Exit Conditions ===
if (strategy.position_size > 0 and rsi_15m > 70)
strategy.exit("Exit Long", from_entry="Long", loss=100, profit=200)
if (strategy.position_size < 0 and rsi_15m < 30)
strategy.exit("Exit Short", from_entry="Short", loss=100, profit=200)
// === Plots ===
plot(shortMA, color=color.blue, title="Short EMA")
plot(longMA, color=color.red, title="Long EMA")
plot(vwap, title="VWAP", color=color.purple, linewidth=2)
plot(adx, title="ADX", color=color.orange)
hline(adxThresh, "ADX Threshold", color=color.gray, linestyle=hline.style_dashed)