The dual EMA crossover trading strategy is a trend following strategy that uses the crossover of two EMAs of different lengths to determine market trend and make trades. This simple and straightforward strategy can effectively track medium- to long-term trends, making it very suitable for swing traders.
The strategy mainly uses the values and crossover of a short-term and long-term EMA to determine trend direction. It first calculates a short-term EMA (e.g. 13 periods) and a long-term EMA (e.g. 26 periods), then computes the percentage crossover between the two EMAs. If the short EMA is above the long EMA and the crossover is larger than a threshold (e.g. 5%), it signals an upward trend and long trades are taken. If the short EMA is below the long EMA and the crossover is larger than the threshold, it signals a downward trend and short trades are taken. Trades are closed when price crosses back above or below the short EMA.
The key logic is:
This allows the strategy to effectively track medium- to long-term trends and switch direction when the trend changes. The crossover threshold also avoids unnecessary trades during non-trending periods.
Risks can be reduced by:
The strategy can be enhanced in areas like:
Parameter optimization via backtesting to find optimal EMA periods and threshold
Trend filtering using additional indicators like MACD, Bollinger Bands to avoid whipsaws
Stop loss strategies like trailing stops or time-based stops to limit losses
Profit taking by moving stop loss to lock in partial profits after hits
Quantitative optimization using machine learning to auto-tune parameters and filters
Portfolio optimization by combining with non-correlated strategies to lower drawdown and increase robustness
Through parameter optimization, better filters, stop loss, profit taking, and quantitative & portfolio optimization, the strategy can be made more robust, adaptive, and scientifically effective.
The dual EMA crossover is a simple and direct trend following strategy suitable for swing trading. It only requires two EMAs to determine trend direction, ideal for medium- to long-term trend trading. The strategy can also be enhanced through parameter tuning, better filters, stop loss, and other quantitative optimizations to make it more robust. Easy to implement and optimize, it is a recommended trend trading strategy.
/*backtest start: 2023-08-19 00:00:00 end: 2023-08-23 00:00:00 period: 4h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=3 strategy("2-EMA Strategy", overlay=true, initial_capital=100, currency="USD", default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.075) diffMinimum = input(0.95, step=0.01) small_ema = input(13, title="Small EMA") long_ema = input(26, title="Long EMA") ema1 = ema(close, small_ema) ema2 = ema(close, long_ema) orderCondition = ema1 > ema2?((ema1/ema2)*100)-100 > diffMinimum:((ema2/ema1)*100)-100 > diffMinimum longCondition = close > ema1 and ema1 > ema2 if (longCondition and orderCondition) strategy.entry("Long", strategy.long) shortCondition = close < ema1 and ema1 < ema2 if (shortCondition and orderCondition) strategy.entry("Short", strategy.short) strategy.close("Short", when=close > ema1) strategy.close("Long", when=close < ema1) plot(ema(close, small_ema), title="EMA 1", color=green, transp=0, linewidth=2) plot(ema(close, long_ema), title="EMA 2", color=orange, transp=0, linewidth=2)