Strategy vault / Trend following
Multi Exponential Moving Average Crossover Strategy with Volume Based ATR Dynamic Stop Loss Optimization
This strategy is a trading system based on multiple Exponential Moving Average (EMA) crossover signals, combining EMAs of different periods with an ATR-based dynamic stop-loss mechanism. The strategy utilizes EMAs of…

Overview
This strategy is a trading system based on multiple Exponential Moving Average (EMA) crossover signals, combining EMAs of different periods with an ATR-based dynamic stop-loss mechanism. The strategy utilizes EMAs of 10, 39, and 73 periods as primary signal indicators, while incorporating a 143-period higher timeframe EMA as a trend filter, and implements dynamic stop-loss and take-profit targets using the ATR indicator.
Strategy Principles
The core logic is based on multiple EMA crossovers and trend confirmation. A long signal is generated when the short-term EMA (10-period) crosses above the medium-term EMA (39-period), and price is above both the long-term EMA (73-period) and higher timeframe EMA (143-period). Conversely, a short signal is generated when the short-term EMA crosses below the medium-term EMA, and price is below both longer-term EMAs. The strategy implements a risk-reward ratio of 1:2 using 1x ATR for stop-loss and 2x ATR for take-profit targets.
Strategy Advantages
- Multiple timeframe confirmation: Integration of different period EMAs effectively reduces false breakout risks
- Dynamic stop-loss mechanism: ATR-based stops adapt to market volatility
- Trend following effectiveness: Higher timeframe EMA filtering ensures trade direction aligns with major trends
- Optimized risk-reward ratio: 1:2 risk-reward setting enhances expected returns
- High signal reliability: Multiple indicator confirmations significantly improve trade signal quality
Strategy Risks
- Ranging market risk: Frequent false signals may occur in sideways markets
- Lag risk: Multiple moving average systems have inherent lag, potentially missing optimal entry points
- Gap risk: Severe volatility may cause stop-loss failures
- Parameter sensitivity: Multiple timeframe parameter selection significantly impacts strategy performance
- Market environment dependence: Strategy performs better in strong trends but may underperform in other conditions
Strategy Optimization Directions
- Incorporate volume indicators: Add volume confirmation to enhance signal reliability
- Add trend strength filtering: Consider including ADX or other trend strength indicators
- Optimize parameter adaptation: Dynamically adjust EMA parameters based on market conditions
- Improve stop-loss mechanism: Consider adding trailing stops or composite stop-loss strategies
- Enhanced market environment analysis: Introduce volatility indicators for market condition classification
Summary
This strategy builds a trading system combining trend following and risk management through multiple EMA crossovers and ATR-based dynamic stops. Its main strengths lie in multiple timeframe confirmation mechanisms and dynamic position management, while being mindful of ranging market and lag risks. Strategy stability and profitability can be further enhanced through volume confirmation, trend strength filtering, and other optimizations. In practical application, parameters should be adjusted according to different market environments and trading instrument characteristics.
Source Pine Script
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-28 00:00:00
period: 2d
basePeriod: 2d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Enhanced EMA Crossover Strategy", overlay=true)
// Define the EMA lengths
ema_short_length = 10
ema_long_length = 39
ema_filter_length = 73
ema_higher_tf_length = 143
// Calculate the EMAs
ema_short = ta.ema(close, ema_short_length)
ema_long = ta.ema(close, ema_long_length)
ema_filter = ta.ema(close, ema_filter_length)
ema_higher_tf = request.security(syminfo.tickerid, "D", ta.ema(close, ema_higher_tf_length))
// Calculate ATR for volatility-based stop loss and take profit
atr_length = 14
atr = ta.atr(atr_length)
// Plot the EMAs
plot(ema_short, title="EMA 10", color=color.blue)
plot(ema_long, title="EMA 35", color=color.red)
plot(ema_filter, title="EMA 75", color=color.orange)
plot(ema_higher_tf, title="EMA Higher TF", color=color.purple)
// EMA crossover conditions with EMA 75 and higher timeframe EMA filter
longCondition = ta.crossover(ema_short, ema_long) and close > ema_filter and close > ema_higher_tf
shortCondition = ta.crossunder(ema_short, ema_long) and close < ema_filter and close < ema_higher_tf
// Execute long trade with dynamic stop loss and take profit
if (longCondition)
strategy.entry("Long", strategy.long)
strategy.exit("Take Profit/Stop Loss", "Long", limit=close + 2 * atr, stop=close - 1 * atr)
// Execute short trade with dynamic stop loss and take profit
if (shortCondition)
strategy.entry("Short", strategy.short)
strategy.exit("Take Profit/Stop Loss", "Short", limit=close - 2 * atr, stop=close + 1 * atr)
// Plot signals on the chart
plotshape(series=longCondition, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal", text="BUY")
plotshape(series=shortCondition, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal", 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.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Multi-Exponential-Moving-Average-Crossover-Strategy-with-Volume-Based-ATR-Dynamic-Stop-Loss-Optimization.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- 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
- Multi Factor Trend Price Action Strategy with Dynamic Risk Management SystemPine Script · Trend following · 2h
- DPO EMA Trend Crossover Quantitative Strategy ResearchPine Script · Trend following · 1d
- Dual EMA Crossover Trend Following Strategy with ATR and ADX FiltersPine Script · Trend following · 1d
- Advanced Multi Indicator Trend Confirmation Trading StrategyPine Script · Trend following · 1d
- Advanced Quantitative Trading Multi Moving Average Crossover System with Volume Filter StrategyPine Script · Trend following · 1d
- Multi Factor Trend Tracking Dynamic Risk Management Stock Trading StrategyPine Script · Trend following · 1d