
The Dynamic Threshold Triple Running Moving Average Trend Trading Strategy is a quantitative trading method based on a multi-layered moving average system. This strategy utilizes three Running Moving Averages (RMAs) of different periods to determine market trend direction and identify trading opportunities. Additionally, the strategy incorporates the Relative Strength Index (RSI) and candlestick structure analysis to provide higher probability entry signals. The strategy features a dynamic threshold system that automatically adjusts according to different market types (Forex, Gold, and Cryptocurrency), allowing it to adapt to the volatility characteristics of various asset classes.
The core of this strategy is a three-layer RMA system and dynamic threshold detection mechanism:
Triple RMA System:
Trend Direction Determination:
Dynamic Threshold System:
Entry Conditions:
Take Profit and Stop Loss Setup:
Adaptive Market Type:
Multi-layered Confirmation Mechanism:
Trend Strength Quantification:
Visualization of Trend Status:
Rational Take Profit and Stop Loss Mechanism:
False Signals in Oscillating Markets:
Parameter Sensitivity:
Fixed Stop Loss Risk:
Reliance on Historical Backtesting Parameters:
Signal Lag:
Adaptive Threshold Optimization:
Enhanced Stop Loss Mechanism:
Market State Classification Optimization:
Time Filter:
Partial Profit Locking:
Filter Tuning:
The Dynamic Threshold Triple Running Moving Average Trend Trading Strategy is a well-structured quantitative trading system that provides an intelligent market adaptation mechanism through a three-layer RMA system and dynamic threshold judgment. The strategy combines the advantages of trend following, momentum confirmation, and price structure analysis, and is optimized for the volatility characteristics of different asset classes.
The main advantages of the strategy lie in its multi-layered confirmation mechanism and market adaptability, effectively reducing false signals and maintaining stability under different market conditions. However, it also faces risks such as false signals in oscillating markets and parameter sensitivity.
There is significant room for improvement through implementing adaptive threshold calculations, enhancing stop loss mechanisms, and optimizing market state classification. Particularly, dynamic stop losses and profit locking features based on ATR can significantly improve risk management capabilities, maintaining strategy robustness across various market environments.
For quantitative investors pursuing trend trading, this strategy provides a solid framework that can be further customized and optimized according to individual risk preferences and capital management principles.
/*backtest
start: 2025-03-18 00:00:00
end: 2025-04-02 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"TRX_USD"}]
*/
//@version=5
strategy("RMA Strategy - Weekly Dynamic Thresholds", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// === User Inputs ===
fastLen = input.int(9, title="Fast RMA")
midLen = input.int(21, title="Mid RMA")
slowLen = input.int(50, title="Slow RMA")
rsiLen = input.int(8, title="RSI Length")
slPoints = input.float(10, title="Stop Loss (Points)")
// === Weekly Threshold Inputs ===
forexThreshold = input.float(0.12, title="Forex Weekly Avg RMA Distance (%)", step=0.01)
goldThreshold = input.float(0.15, title="Gold Weekly Avg RMA Distance (%)", step=0.01)
cryptoThreshold = input.float(0.25, title="Crypto Weekly Avg RMA Distance (%)", step=0.01)
// === Select Current Market Type ===
marketType = input.string("FOREX", title="Asset Class", options=["FOREX", "GOLD", "CRYPTO"])
// === Use appropriate threshold based on selected market
weeklyThreshold = marketType == "FOREX" ? forexThreshold :
marketType == "GOLD" ? goldThreshold :
cryptoThreshold // Default to crypto if somehow not matched
// === RMA Calculations ===
fastRMA = ta.rma(close, fastLen)
midRMA = ta.rma(close, midLen)
slowRMA = ta.rma(close, slowLen)
// === RSI Calculation ===
rsi = ta.rsi(close, rsiLen)
// === Trend Structure ===
bullish = fastRMA > midRMA and midRMA > slowRMA
bearish = fastRMA < midRMA and midRMA < slowRMA
// === Candle Break Conditions ===
longCandleBreak = close > high[1]
shortCandleBreak = close < low[1]
// === Distance and Trend Strength Check ===
distance = math.abs(fastRMA - midRMA)
distancePct = distance / midRMA * 100
isTrending = distancePct >= weeklyThreshold
// === Entry Conditions ===
longSignal = bullish and ta.crossover(close, midRMA) and rsi > 50 and longCandleBreak
shortSignal = bearish and ta.crossunder(close, midRMA) and rsi < 50 and shortCandleBreak
// === TP and SL Setup ===
takeProfitPriceLong = slowRMA
stopLossPriceLong = close - slPoints * syminfo.mintick
takeProfitPriceShort = slowRMA
stopLossPriceShort = close + slPoints * syminfo.mintick
// === Trade Execution ===
if (longSignal)
strategy.entry("Long", strategy.long)
strategy.exit("TP/SL Long", from_entry="Long", limit=takeProfitPriceLong, stop=stopLossPriceLong)
if (shortSignal)
strategy.entry("Short", strategy.short)
strategy.exit("TP/SL Short", from_entry="Short", limit=takeProfitPriceShort, stop=stopLossPriceShort)
// === Highlight RMAs Based on Trending Strength ===
fastColor = isTrending ? color.green : color.blue
midColor = isTrending ? color.red : color.blue
slowColor = color.orange
// === Plot RMAs ===
plot(fastRMA, color=fastColor, title="Fast RMA")
plot(midRMA, color=midColor, title="Mid RMA")
plot(slowRMA, color=slowColor, title="Slow RMA")