0bps

Strategy vault / Momentum

Dual EMA Trend Momentum Trading Strategy

This is a quantitative trading strategy based on dual EMA crossover and trend following. The strategy primarily utilizes 47-period and 95-period Exponential Moving Averages (EMA) to capture market trends, executing…

Author
ChaoZhang
Complexity
Starter · 42 lines
Parameters
0
Backtest bar
1d · swing
Tested on
BTC/USDT · futures

IMG

Overview

This is a quantitative trading strategy based on dual EMA crossover and trend following. The strategy primarily utilizes 47-period and 95-period Exponential Moving Averages (EMA) to capture market trends, executing trades based on EMA crossover signals. Operating on a 15-minute timeframe, it combines technical analysis and momentum trading principles to achieve consistent trading returns.

Strategy Principles

The core mechanism relies on identifying trend changes through crossovers between short-term EMA (47-period) and long-term EMA (95-period). Buy signals are generated when the short-term EMA crosses above the long-term EMA, while positions are closed when the short-term EMA crosses below. This design is based on price momentum and trend continuation principles, using EMA crossovers to confirm trend transition points.

Strategy Advantages

  1. Clear Signals: Dual EMA crossovers provide explicit entry and exit signals, reducing uncertainty from subjective judgment.
  2. Trend Following: The strategy effectively captures medium to short-term trends, generating profits during trend continuation.
  3. High Automation: Simple and clear strategy logic enables easy programming implementation and backtesting.
  4. Strong Adaptability: Strategy can be adapted to different market environments by adjusting EMA periods.
  5. Controlled Risk: Systematic trading rules help control emotional fluctuations and maintain trading discipline.

Strategy Risks

  1. Poor Performance in Ranging Markets: Frequent false breakouts in sideways markets may lead to consecutive losses.
  2. Lag Effect: EMA indicators have inherent lag, potentially missing optimal entry points or experiencing larger drawdowns during trend reversals.
  3. Parameter Dependency: Strategy performance heavily relies on EMA period selection, requiring different parameters for different markets.
  4. Capital Management: Lack of comprehensive stop-loss mechanisms may result in significant losses during volatile periods.

Optimization Directions

  1. Incorporate Volatility Indicators: Add ATR indicator for dynamic stop-loss adjustment to enhance risk control.
  2. Add Trend Filters: Combine RSI or MACD indicators to screen for more reliable trading signals.
  3. Optimize Parameter Selection: Implement machine learning methods for automatic selection of optimal EMA periods in different market environments.
  4. Improve Capital Management: Enhance position sizing and risk control modules, set maximum loss percentage per trade.
  5. Include Market Environment Analysis: Introduce market structure analysis to reduce trading frequency or pause trading during ranging markets.

Conclusion

This is a well-structured and logically rigorous trend-following strategy. It captures market trends through dual EMA crossovers, offering good operability and scalability. While certain limitations exist, continuous optimization and improvement can develop it into a stable and reliable trading system. The key is to flexibly adjust parameters based on different market characteristics and establish comprehensive risk control mechanisms.

Source Pine Script

/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-27 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("EMA Crossover Strategy", overlay=true)

// Define the EMA periods
shortEmaPeriod = 47
longEmaPeriod = 95

// Calculate EMAs
ema11 = ta.ema(close, shortEmaPeriod)
ema21 = ta.ema(close, longEmaPeriod)

// Plot EMAs on the chart
plot(ema11, title="11 EMA", color=color.blue, linewidth=2)
plot(ema21, title="21 EMA", color=color.red, linewidth=2)

// Generate trading signals
longSignal = ta.crossover(ema11, ema21)
shortSignal = ta.crossunder(ema11, ema21)

// Execute trades based on signals
if (longSignal)
    strategy.entry("Buy", strategy.long)

if (shortSignal)
    strategy.close("Buy")

// Optional: Plot buy and sell signals on the chart
plotshape(series=longSignal, location=location.belowbar, color=color.green, style=shape.labelup, text="Buy")
plotshape(series=shortSignal, location=location.abovebar, color=color.red, style=shape.labeldown, text="Sell")

// Plot buy/sell signals on the main chart
plotshape(series=longSignal, location=location.belowbar, color=color.green, style=shape.labelup, text="Buy")
plotshape(series=shortSignal, location=location.abovebar, color=color.red, style=shape.labeldown, text="Sell")

Published by ChaoZhang on the FMZ strategy square · last modified 2024-11-29. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.

Build this with AgenKit

A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Dual-EMA-Trend-Momentum-Trading-Strategy.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. Get tests, backtest, risk controls and a paper-trading switch

Understand it first

Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.

Related specs

esc

Try , , or .

↑↓ move↵ open