OPEN-SOURCE SCRIPT
DEMA ATR Strategy [PrimeAutomation]

⯁ OVERVIEW
The DEMA ATR Strategy combines trend-following logic with adaptive volatility filters to identify strong momentum phases and manage trades dynamically.
It uses a Double Exponential Moving Average (DEMA) anchored to ATR volatility bands, creating a self-adjusting trend baseline.
When the adjusted DEMA shifts direction, the strategy enters positions and scales out profit in phases based on ATR-driven targets.
This system adapts to volatility, filters noise, and seeks sustained directional moves.
⯁ KEY FEATURES
⯁ STRATEGY LOGIC
⯁ WHEN TO USE
⯁ CONCLUSION
This strategy blends DEMA trend recognition with ATR-based volatility adaptation to generate cleaner directional entries and structured take-profit exits. It is designed to capture momentum phases while avoiding noise-driven false signals, delivering a disciplined and scalable trend-following approach.
The DEMA ATR Strategy combines trend-following logic with adaptive volatility filters to identify strong momentum phases and manage trades dynamically.
It uses a Double Exponential Moving Average (DEMA) anchored to ATR volatility bands, creating a self-adjusting trend baseline.
When the adjusted DEMA shifts direction, the strategy enters positions and scales out profit in phases based on ATR-driven targets.
This system adapts to volatility, filters noise, and seeks sustained directional moves.
⯁ KEY FEATURES
- DEMA-Volatility Hybrid Filter
Uses Double EMA with ATR expansion/compression logic to form a dynamic trend baseline. - Directional Shift Entries
Entries occur when the adjusted DEMA flips trend (bullish crossover or bearish crossunder vs its past value). - Noise Reduction Mechanism
ATR range caps extreme moves and prevents false flips during choppy volatility spikes. - Multi-Level Take Profits
Targets scale out positions at 1×, 2×, and 3× ATR multiples in the trade direction. - Volatility-Adaptive Targets
ATR multiplier ensures profit targets expand/contract based on market conditions. - Single-Direction Exposure
No pyramiding; the strategy flips position only when trend shifts. - Automated Trade Finalization
When all profit targets trigger, the position is fully closed.
⯁ STRATEGY LOGIC
- Trend Direction:
DEMA baseline is modified using ATR upper/lower envelopes.
• If the adjusted DEMA rises above previous value → Bullish
• If it falls below previous value → Bearish - Entry Rules:
• Enter Long when bullish shift occurs and no long position exists
• Enter Short when bearish shift occurs and no short position exists - Take Profit Logic:
3 partial exits for each trade based on ATR:
• TP1 = ±1× ATR
• TP2 = ±2× ATR
• TP3 = ±3× ATR
Profit distribution: 30% / 30% / 40% - Exit Conditions:
• Exit when all TPs hit (full scale-out if sum of all TPs 100%)
• Opposite trend signal closes current trade and opens new one
⯁ WHEN TO USE
- Trending environments
- Medium–high volatility phases
- Swing trading and intraday trend plays
- Markets that respect momentum continuation (crypto, indices, FX majors)
⯁ CONCLUSION
This strategy blends DEMA trend recognition with ATR-based volatility adaptation to generate cleaner directional entries and structured take-profit exits. It is designed to capture momentum phases while avoiding noise-driven false signals, delivering a disciplined and scalable trend-following approach.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.