Overview
The Multi-timeframe Trend Following Strategy Based on EMA and Supertrend Combination is a comprehensive quantitative trading system that primarily captures market trends and generates trading signals through a combination of multiple moving averages and the Supertrend indicator. The strategy employs three exponential moving averages (EMAs) of different periods as a preliminary judgment of trend direction, while incorporating the ATR-based (Average True Range) Supertrend indicator as the main basis for entry and exit points. The strategy is particularly suitable for Renko charts, which filter market noise and more clearly display price movement trends.
Strategy Principles
The core principle of this strategy is based on a collaborative confirmation mechanism of multi-layered technical indicators, including the following key components:
Multiple EMA Crossover System: The strategy uses three exponential moving averages with different periods (9, 15, and 15) to determine the overall market trend direction. When the fast EMA (9-period) is above the slow EMA (15-period), it is identified as an uptrend; conversely, it is a downtrend.
Supertrend Indicator: Upper and lower bands are calculated based on ATR (Average True Range). When the price breaks through the upper band, it switches to a bullish trend; when it breaks through the lower band, it switches to a bearish trend. The strategy uses a 10-period ATR with a multiplier parameter of 3.0.
Trend Confirmation Mechanism: The strategy only generates trading signals when the EMA trend direction aligns with the Supertrend direction, which reduces the probability of false signals.
Signal Generation Logic:
- Buy signal: When Supertrend switches from downtrend to uptrend, and simultaneously the fast EMA is above the slow EMA
- Sell signal: When Supertrend switches from uptrend to downtrend, and simultaneously the fast EMA is below the slow EMA
- Position Management: The strategy uses a percentage of equity (100%) as the default position size, providing a dynamic position adjustment mechanism based on account size.
Strategy Advantages
Multiple Confirmation Mechanism: By requiring consistency between EMA trends and Supertrend signals, it significantly reduces the possibility of erroneous trading signals, enhancing the robustness of the strategy.
Trend Following Effectiveness: The strategy excels at capturing medium to long-term trends, performing exceptionally well in markets with strong continuity, allowing it to follow trends and hold positions long enough to obtain substantial profits.
Adaptability: The Supertrend indicator, calculated based on ATR, automatically adjusts according to market volatility, maintaining effectiveness across different volatility environments.
Balanced Trading Frequency: The strategy achieves a good balance in trading frequency—neither too frequent to cause high slippage and fees, nor too conservative to miss important opportunities.
Visualization Effects: The strategy visually displays the current trend status through color-filled areas, with green indicating uptrends and red indicating downtrends, enhancing traders' perception of market conditions.
Synergy with Renko Charts: The strategy works particularly well with Renko charts, further reducing the impact of market noise and improving signal quality.
Strategy Risks
Trend Reversal Risk: In oscillating markets, the strategy may encounter frequent false breakouts, leading to multiple entries and exits and resulting in consecutive losses. Consider introducing volatility filters or additional confirmation conditions to reduce false signals.
Parameter Sensitivity: The strategy's performance is relatively sensitive to parameter settings such as EMA periods and ATR multipliers, with optimal parameters potentially varying significantly under different market conditions. It is recommended to find robust parameter combinations through backtesting across different market environments.
Lag Issues: As a trend following strategy, there is a certain lag in signals, potentially missing part of the initial trend or giving back some profits at the end of trends. Consider adding more sensitive short-term indicators as supplements to optimize entry and exit timing.
Position Risk: The current strategy uses a fixed 100% equity percentage as position size, which may bring excessive risk in highly volatile markets. Consider introducing dynamic position management mechanisms to adjust position size based on market volatility and signal strength.
Lack of Stop-Loss Mechanism: There is no explicit stop-loss setting in the code, which may lead to significant losses in sudden trend reversals. Appropriate stop-loss conditions should be added to limit the maximum loss per trade.
Strategy Optimization Directions
Diversify Parameter Selection: Currently, two EMA periods are set to the same value (15). It is recommended to differentiate them, such as 9, 15, 21, to provide clearer trend hierarchy judgment.
Add Filtering Conditions: Consider adding additional conditions such as volume confirmation, volatility filtering, or market structure assessment to further reduce false signals. For example, only allow trading when market volatility is within a specific range.
Optimize Position Management: Introduce ATR-based dynamic position management to reduce positions during high volatility and increase positions during low volatility, balancing risk and return.
Add Stop-Loss and Take-Profit Mechanisms: Set up ATR-based dynamic stop-losses and risk-reward ratio-based take-profit conditions to optimize fund management and risk control.
Time Filters: Analyze the strategy's performance during different time periods to avoid inefficient or high-risk trading sessions, trading only during the periods when the strategy performs best.
Improve Trend Judgment Logic: The current strategy's trend judgment is relatively simple. Consider adding more complex trend assessment methods, such as considering longer-period trend directions or using price structure (highs and lows) analysis to assist judgment.
Optimize Naming Conventions: The current code uses non-standard variable names (such as Curly_Fries, Popeyes, etc.). These should be changed to more descriptive professional names to improve code readability and maintainability.
Summary
The Multi-timeframe Trend Following Strategy Based on EMA and Supertrend Combination is a well-designed quantitative trading system that effectively captures market trends and controls risk by combining moving average crossover systems with ATR channel breakout strategies. The strategy is particularly suitable for use in market environments with clear trends and has especially good compatibility with Renko charts.
The main advantages of this strategy lie in its multiple indicator confirmation mechanism and adaptability, maintaining good stability across different market environments. At the same time, the strategy also has issues such as parameter sensitivity and trend reversal risk, which need to be optimized through parameter optimization, additional filtering conditions, and improved fund management.
Of particular note is the need to add stop-loss mechanisms, optimize position management strategies, and improve the variable naming conventions in the code. Through these optimizations, the strategy's risk-reward characteristics and long-term stability are expected to be significantly enhanced.
For traders looking to use trend-following strategies, this is a good foundational framework that can be further customized and optimized according to personal risk preferences and specific market characteristics.
Strategy source code
/*backtest
start: 2025-03-31 00:00:00
end: 2025-04-01 00:00:00
period: 2m
basePeriod: 2m
exchanges: [{"eid":"Futures_Binance","currency":"BNB_USDT"}]
*/
//@version=6
strategy('Supertrend Strategy for Renko', overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
Curly_Fries = input(9, title='Fast')
Popeyes = input(15, title='Medium')
Chicken_Sandwich = input(15, 'Slow')
ema_150 = ta.ema(close, Curly_Fries)
ema_200 = ta.ema(close, Popeyes)
ema_250 = ta.ema(close, Chicken_Sandwich)
a = plot(ema_150, title='EMA9')
b = plot(ema_200, title='EMA15')
c = plot(ema_250, title='EMA15')
ups = ema_150 > ema_250
down = ema_150 < ema_250
mycolor = ups ? color.green : down ? color.red : na
fill(a, c, color=mycolor)
Periods = input(title='ATR Period', defval=10)
src = input(hl2, title='Source')
Multiplier = input.float(title='ATR Multiplier', step=0.1, defval=3.0)
changeATR = input(title='Change ATR Calculation Method?', defval=true)
showsignals = input(title='Show Buy/Sell Signals?', defval=true)
highlighting = input(title='Highlighter On/Off?', defval=true)
atr2 = ta.sma(ta.tr, Periods)
atr = changeATR ? ta.atr(Periods) : atr2
up = src - Multiplier * atr
up1 = nz(up[1], up)
up := close[1] > up1 ? math.max(up, up1) : up
dn = src + Multiplier * atr
dn1 = nz(dn[1], dn)
dn := close[1] < dn1 ? math.min(dn, dn1) : dn
trend = 1
trend := nz(trend[1], trend)
trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
upPlot = plot(trend == 1 ? up : na, title='Up Trend', style=plot.style_linebr, linewidth=2, color=color.new(color.green, 0))
dnPlot = plot(trend == 1 ? na : dn, title='Down Trend', style=plot.style_linebr, linewidth=2, color=color.new(color.red, 0))
buySignal = trend == 1 and trend[1] == -1 and ups
sellSignal = trend == -1 and trend[1] == 1 and down
if buySignal
strategy.entry('Long', strategy.long)
if sellSignal
strategy.close('Long')
strategy.entry('Short', strategy.short)
if trend == 1
strategy.close('Short') // Closes the short if the trend turns bullish
longFillColor = highlighting ? trend == 1 ? color.green : color.white : color.white
shortFillColor = highlighting ? trend == -1 ? color.red : color.white : color.white
fill(upPlot, dnPlot, title='Trend Highlighter', color=longFillColor)
alertcondition(buySignal, title='SuperTrend Buy', message='SuperTrend Buy!')
alertcondition(sellSignal, title='SuperTrend Sell', message='SuperTrend Sell!')
changeCond = trend != trend[1]
alertcondition(changeCond, title='SuperTrend Direction Change', message='SuperTrend has changed direction!')
Strategy parameters
The original address: Multi-timeframe Trend Following Strategy Based on EMA and Supertrend Combination