Strategy vault / Trend following
Dynamic Filtering EMA Cross Strategy for Daily Trend Analysis
This strategy employs a dual moving average system for trend determination and trading decisions, utilizing the relative position of fast and slow exponential moving averages (EMAs) at specific time points to…

Overview
This strategy employs a dual moving average system for trend determination and trading decisions, utilizing the relative position of fast and slow exponential moving averages (EMAs) at specific time points to identify trend initiation, continuation, or termination. The strategy checks the relationship between fast and slow EMAs at a fixed time daily, establishing long positions when the fast line is above the slow line and short positions when it's below.
Strategy Principle
The core of the strategy is based on two EMAs with different periods for trend determination. The fast EMA (default period 10) is more sensitive to price changes, capable of capturing market movements quickly; the slow EMA (default period 50) reflects longer-term trends. The strategy checks the position relationship between these two lines at a specified time each trading day (default 9:00), using EMA crossover signals to determine market trend direction and execute trades. A long position is entered when the fast EMA crosses above the slow EMA, indicating strengthening upward momentum, while a short position is entered when the fast EMA crosses below the slow EMA, indicating strengthening downward momentum.
Strategy Advantages
- Clear and simple trading logic, easy to understand and execute
- Filters noise signals through daily fixed-time checks, reducing false trades
- Employs percentage-based position sizing for effective risk control
- Combines fast and slow moving averages to effectively capture trend initiation and reversal
- Highly adjustable strategy parameters, suitable for different market environments
- High degree of automation, requiring no manual intervention
Strategy Risks
- May generate frequent trades in choppy markets, increasing transaction costs
- Fixed entry timing might miss important price movements
- Moving average systems have inherent lag, potentially causing delayed entries or exits
- May experience significant drawdowns in highly volatile markets
- Improper parameter selection can affect strategy performance
Strategy Optimization Directions
- Incorporate volatility indicators to adjust position sizing during high volatility periods
- Add trend confirmation indicators like MACD or RSI to improve signal reliability
- Optimize entry timing mechanism, considering dynamic time checks based on market characteristics
- Add stop-loss and take-profit mechanisms for better risk control
- Consider incorporating volume analysis to improve signal quality
- Develop adaptive parameter mechanisms for increased flexibility
Summary
The strategy achieves a simple yet effective trend-following trading system by combining a dual EMA system with fixed-time check mechanisms. Its strengths lie in clear logic and high automation, though it faces limitations from moving average lag and fixed entry timing. There remains significant room for improvement through the introduction of additional technical indicators, optimization of parameter selection mechanisms, and enhanced risk control measures. Overall, this represents a practical basic strategy framework that can be further refined and optimized according to specific requirements.
Source Pine Script
/*backtest
start: 2024-12-06 00:00:00
end: 2025-01-04 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Daily EMA Comparison Strategy", shorttitle="Daily EMA cros Comparison", overlay=true)
//------------------------------------------------------------------------------
// Inputs
//------------------------------------------------------------------------------
fastEmaLength = input.int(10, title="Fast EMA Length", minval=1) // Fast EMA period
slowEmaLength = input.int(50, title="Slow EMA Length", minval=1) // Slow EMA period
checkHour = input.int(9, title="Check Hour (24h format)", minval=0, maxval=23) // Hour to check
checkMinute = input.int(0, title="Check Minute", minval=0, maxval=59) // Minute to check
//------------------------------------------------------------------------------
// EMA Calculation
//------------------------------------------------------------------------------
fastEMA = ta.ema(close, fastEmaLength)
slowEMA = ta.ema(close, slowEmaLength)
//------------------------------------------------------------------------------
// Time Check
//------------------------------------------------------------------------------
// Get the current bar's time in the exchange's timezone
currentTime = timestamp("GMT-0", year, month, dayofmonth, checkHour, checkMinute)
// Check if the bar's time equals or passes the daily check time
isCheckTime = (time >= currentTime and time < currentTime + 60 * 1000) // 1-minute tolerance
//------------------------------------------------------------------------------
// Entry Conditions
//------------------------------------------------------------------------------
// Buy if Fast EMA is above Slow EMA at the specified time
buyCondition = isCheckTime and fastEMA > slowEMA
// Sell if Fast EMA is below Slow EMA at the specified time
sellCondition = isCheckTime and fastEMA < slowEMA
//------------------------------------------------------------------------------
// Strategy Execution
//------------------------------------------------------------------------------
// Enter Long
if buyCondition
strategy.entry("Long", strategy.long)
// Enter Short
if sellCondition
strategy.entry("Short", strategy.short)
//------------------------------------------------------------------------------
// Plot EMAs
//------------------------------------------------------------------------------
plot(fastEMA, color=color.blue, title="Fast EMA")
plot(slowEMA, color=color.orange, title="Slow EMA")
Published by ChaoZhang on the FMZ strategy square · last modified 2025-01-06. 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/Dynamic-Filtering-EMA-Cross-Strategy-for-Daily-Trend-Analysis.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
- Adaptive ATR and RSI Trend Following Strategy with Trailing Stop LossPine Script · Trend following · 1h
- Advanced Multi Indicator Multi Dimensional Trend Cross Quantitative StrategyPine Script · Trend following · 3h
- Bollinger Bands and RSI Trend Following StrategyPine Script · Trend following · 1h
- Dual ATR Channel Trend Following StrategyPine Script · Trend following · 15m
- Dynamic Dual EMA Crossover Strategy with Adaptive Profit Loss ControlPine Script · Trend following · 1d
- EMA SMA Multi Indicator Comprehensive Trend Following StrategyPine Script · Trend following · 1h