Skip to content
All library documents

Filtering EMA Trends by Duration with ATR-Based Exits

Article TradingView scripts

Summary

This rules-based strategy pairs a fast and a slow exponential moving average with a minimum-duration filter. It classifies the market as bullish when the fast average is above the slow average and bearish when it is below. A counter tracks consecutive bars in each state and resets when that alignment ends. The strategy enters long or short only after the relevant state lasts at least the configured minimum, and only when its current position permits the new direction.

Risk management uses ATR to set a stop distance from the average entry price and a profit target at a configurable multiple of that distance. The script’s example defaults specify moving-average lengths, a persistence threshold, ATR settings, and a reward-to-risk multiple, but the document reports no backtest results. The accompanying explanation presents the framework as an educational way to study trend duration and reduce reactions to brief direction changes. Its performance may vary across instruments, timeframes, and market conditions; persistence alone does not predict future prices.

Key ideas

  • Trend direction is defined by the relative position of fast and slow exponential moving averages.
  • A consecutive-bar counter requires the alignment to persist for a minimum duration before entry.
  • The strategy can enter long in a persistent bullish state and short in a persistent bearish state.
  • ATR sets stop distances and profit targets using a configurable reward-to-risk multiple.
  • The document supplies no performance evidence and cautions that results depend on market and timeframe.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.