DEMA, or Double Exponential Moving Average, is a moving-average overlay designed to reduce the lag of a standard EMA. Developed by Patrick Mulloy and published in Technical Analysis of Stocks & Commodities in 1994, it uses the formula DEMA = 2 × EMA(n) − EMA(EMA(n)), so the line reacts faster to price changes than a comparable EMA or SMA. In TradingView, DEMA is available as a built-in indicator — you can add it from the indicator search without writing any Pine Script. The trade-off is important: DEMA can detect trend changes earlier, but it also produces more false crossover signals in sideways or choppy markets. It is most useful for traders who want faster trend signals; long-term investors who prefer stability often find standard EMA or SMA sufficient.
Risk notice: DEMA signals are not buy or sell recommendations. No moving average guarantees profitable outcomes. Always backtest on your own data, define your risk parameters, and confirm signals with additional tools before making any trading decision.
Key Takeaways
- DEMA cuts lag by computing EMA of the EMA and using it as a correction term, producing a line that tracks price more tightly than SMA or EMA.
- TradingView includes DEMA as a built-in indicator — search "Double EMA" in the Indicators panel and click to apply it.
- Best suited for active traders who need responsive trend signals; the added sensitivity also means more potential whipsaws in range-bound conditions.
- Pair DEMA with other tools — RSI, MACD, ATR, or volume filters help reduce false signals.
- Common signal setups include price crossovers, dual-DEMA crossovers, and using DEMA as a dynamic support or resistance reference.
How the DEMA Formula Works
Despite its name, DEMA does not simply double the EMA value. The name refers to the fact that the formula involves an EMA of the EMA. The full calculation:
EMA1 = EMA(n) of price
EMA2 = EMA(n) of EMA1
DEMA = (2 × EMA1) − EMA2
What each component does
| Component | Role | Effect |
|---|---|---|
| EMA1 | Standard EMA of price | Provides the base trend line with moderate lag |
| EMA2 | EMA applied to EMA1 (double-smoothed) | Adds even more lag — used as the correction term |
| 2 × EMA1 | Creates a lag-correction term when paired with −EMA2 | Amplifies the weight of recent price data |
| − EMA2 | Subtracts the double-smoothed component | Removes accumulated lag from older data |
The key insight: EMA2 lags more than EMA1. By subtracting EMA2 from 2×EMA1, the formula cancels out the lag embedded in the double-smoothed layer, leaving a smoother line that still tracks price closely.
Warm-Up Bars and Platform Differences
Because DEMA needs to compute EMA of the EMA, it theoretically requires 2 × period − 1 data points before producing its first meaningful value. For a 9-period DEMA, that is at least 17 bars; for a 50-period DEMA, at least 99 bars. In practice, different platforms seed and warm up EMA calculations differently, so the exact number of bars before DEMA stabilizes can vary. TradingView handles warm-up automatically — DEMA simply does not appear on the chart until enough historical data is available.
Step-by-step calculation example
Using a 5-period DEMA with hypothetical closing prices:
- Gather prices: Day 1 $150.25, Day 2 $152.10, Day 3 $151.75, Day 4 $153.20, Day 5 $154.15, Day 6 $152.80
- Calculate smoothing multiplier: k = 2 ÷ (5 + 1) = 0.333
- Seed EMA1: Simple average of first 5 days = $152.29
- Update EMA1 for Day 6: $152.29 + 0.333 × ($152.80 − $152.29) ≈ $152.46
- Calculate EMA2 by applying the same EMA formula to the EMA1 series
- Apply DEMA formula: DEMA = (2 × $152.46) − EMA2 value for Day 6
In practice, TradingView computes this on every bar automatically.
How to Add DEMA in TradingView
DEMA is a built-in TradingView indicator. No installation or Pine Script knowledge is needed.
Step 1: Open a chart
Navigate to TradingView and open a chart for any asset — stocks, forex, crypto, futures, or indices.
Step 2: Open the Indicators panel
Click the Indicators button above the chart (the fx icon). You can also use TradingView's keyboard shortcut to open indicator search — check TradingView's current keyboard shortcuts page for the exact key combination, as it may change across platform updates.
Step 3: Search for DEMA
Type "Double EMA" or "DEMA" in the search box. You will see "Double Exponential Moving Average (EMA)" listed under the Built-in category. Click it to add it to your chart.
Step 4: Configure the settings
Click the gear icon next to the indicator name on the chart to open settings. Default values reflect TradingView's current defaults at time of writing — verify against the TradingView Help Center for the most current interface:
| Setting | Typical Default | What to adjust |
|---|---|---|
| Length | 9 | Period for the EMA calculation. Try 5–21 for short-term, 50–200 for longer-term trend reference |
| Source | close | Usually keep as close; high/low/ohlc4 are alternatives |
| Offset | 0 | Shifts the DEMA line forward or backward; rarely needed |
| Style | Solid line | Adjust color, thickness, or line type for visual clarity |
Step 5: Add a second DEMA for crossover setups
Repeat Steps 2–4 and set a different period (e.g., DEMA 9 and DEMA 21). This gives you a fast/slow pair to observe crossover signals.
Using DEMA in Pine Script (v5 example)
If you build custom strategies, TradingView's Pine Script v5 provides the ta.dema() function. Consult the TradingView Pine Script Reference Manual to confirm the current function signature, as Pine Script continues to evolve:
//@version=5
indicator("DEMA Demo", overlay=true)
length = input.int(9, "DEMA Length")
demaValue = ta.dema(close, length)
plot(demaValue, "DEMA", color=color.orange, linewidth=2)
This plots DEMA directly on the price chart and allows you to build alerts, crossover logic, or full strategies around it.
DEMA vs EMA vs SMA: Comparison
| Feature | SMA | EMA | DEMA |
|---|---|---|---|
| Formula | Simple average of last n prices | Weighted average favoring recent data | 2 × EMA − EMA(EMA) |
| Weight on recent data | Equal | Exponentially decreasing | Heaviest on recent prices |
| Lag | Highest | Moderate | Lowest |
| Responsiveness | Slowest | Moderate | Fastest |
| Noise sensitivity | Least sensitive | Moderate | Most sensitive |
| Best used for | Long-term trend confirmation | General-purpose trend analysis | Faster trend-change detection |
| Often used by | Long-term investors | Most traders | Day traders, swing traders |
| Warm-up bars needed | n | n | ~2n − 1 (platform-dependent) |
DEMA vs EMA: Which should you use?
| If you… | Consider… |
|---|---|
| Want to catch trend changes early and accept more false signals | DEMA |
| Want a balanced lag/noise trade-off for most market conditions | EMA |
| Prioritize trend confirmation over signal speed | SMA |
| Are trading in choppy, range-bound conditions | SMA or EMA (DEMA can whipsaw) |
| Are building an automated strategy and need low lag | DEMA with confirmation filters |
Common DEMA Signal Setups
These setups describe signal patterns commonly discussed in technical analysis literature. They are not trading recommendations and do not guarantee profitable outcomes. Always validate with your own backtests, risk rules, and market context.
Price crossover signals
The simplest DEMA setup watches price crossing the DEMA line:
- Price crosses above DEMA → possible bullish signal to investigate
- Price crosses below DEMA → possible bearish signal to investigate
Because DEMA has less lag, these crossovers occur earlier than equivalent EMA or SMA crossovers. The trade-off: more frequent signals also means more potential whipsaws in choppy markets.
Dual-DEMA crossover
Add two DEMAs with different periods — for example DEMA(9) as the fast line and DEMA(21) as the slow line:
| Signal | Condition | Interpretation |
|---|---|---|
| Bullish crossover | Fast DEMA crosses above slow DEMA | Possible bullish bias to investigate |
| Bearish crossover | Fast DEMA crosses below slow DEMA | Possible bearish bias to investigate |
These crossovers are not standalone buy or sell signals. For higher-conviction setups, combine DEMA crossovers with a volume filter (e.g., only consider signals when volume is above its 20-period average) or RSI confirmation.
DEMA as dynamic support and resistance reference
In a trending market, DEMA can serve as a floating reference level:
- Uptrend: Price pulls back toward the DEMA line and bounces — the DEMA may act as support
- Downtrend: Price rallies toward the DEMA line and reverses — the DEMA may act as resistance
A 21-period or 50-period DEMA on the daily chart is commonly used for this purpose. When price repeatedly respects the DEMA level, it can suggest trend strength. When price cuts through without hesitation, it may indicate the trend is weakening — but always look for additional confirmation.
Common DEMA Length Starting Points
These are frequently cited starting points, not optimal parameters. The right setting depends on your instrument, timeframe, execution costs, and slippage — and requires backtesting on your own data.
| Trading Style | Fast DEMA | Slow DEMA | Timeframe |
|---|---|---|---|
| Scalping | 5 | 13 | 1m – 5m |
| Day trading | 9 | 21 | 5m – 1H |
| Swing trading | 21 | 50 | 1H – Daily |
| Position trading | 50 | 200 | Daily – Weekly |
Before using a DEMA signal — 5 things to check
- Trend context: Is the broader market in a clear trend or range-bound? DEMA performs differently in each condition.
- Volume confirmation: Does volume support the move? Weak-volume crossovers are more likely to fail.
- RSI alignment: Is momentum supporting the signal direction (e.g., RSI above 50 for a bullish crossover)?
- Higher-timeframe agreement: Does the DEMA signal align with the trend on the next higher timeframe?
- Risk/reward ratio: Is there a logical stop-loss level that gives a reasonable risk-to-reward ratio before entry?
When DEMA Works Best — and When It Doesn't
DEMA is most useful when:
- Markets are trending clearly — DEMA tracks directional moves with minimal lag
- Volatility is elevated and directional — post-breakout moves after volatility expands tend to suit DEMA well
- You need relatively fast signals — day trading, scalping, or swing trading on lower timeframes
- Used as part of a multi-tool system — combined with RSI for momentum, ATR for stop-loss sizing, or MACD for trend confirmation
DEMA can mislead when:
- Markets are range-bound or choppy — extra sensitivity generates frequent crossover signals that lead to whipsaws
- Trading volume is very low — holiday weeks or illiquid instruments can produce unreliable signals
- You are over-optimizing period settings — fitting DEMA precisely to historical data often fails in live markets
- Used as a standalone indicator — no single moving average provides sufficient context for consistent trading decisions
Common Mistakes When Using DEMA
-
Treating reduced lag as a universal advantage. Less lag means faster signals, but it also means reacting to noise that EMA or SMA would filter out. In sideways markets, some lag can be protective.
-
Using DEMA alone. Every moving average, including DEMA, is a lagging indicator — it can only confirm what has already happened. Pair it with at least one non-correlated tool such as volume, an oscillator, or price structure analysis.
-
Overtrading on every crossover. DEMA generates more crossover signals than EMA. Not every crossover is a valid setup. Filter with higher-timeframe trend direction, volume, or momentum.
-
Ignoring the warm-up period. DEMA(50) needs approximately 99 bars before it stabilizes. On a newly listed instrument or a very short chart history, early DEMA values may be unreliable.
-
Confusing DEMA with "2 × EMA." The word "double" refers to the formula's structure (EMA of EMA used as a lag-correction term), not to multiplying the EMA value by two. Plotting 2×EMA produces a magnified EMA line — not a DEMA.
Practical Next Steps
- Open TradingView and add the built-in DEMA to a chart you follow. Start with the default period setting and observe how it reacts compared to your usual moving average.
- Add a second DEMA with a longer period (21 or 50) and watch for crossovers over the next several sessions.
- Combine DEMA with RSI — consider DEMA crossover signals only when RSI supports the direction (above 50 for potential longs, below 50 for potential shorts). This is a starting point, not a guaranteed setup.
- Build a testing habit before risking capital. Charting platforms and practice environments like ChartMini can help you get comfortable reading moving averages and planning your approach before you commit real money.
- Compare DEMA and EMA side-by-side — add both with the same period to visually see the lag difference in action.
FAQ
What is the Double Exponential Moving Average (DEMA)?
DEMA is a technical indicator developed by Patrick Mulloy, published in Technical Analysis of Stocks & Commodities in 1994. Its formula — DEMA = 2 × EMA(n) − EMA(EMA(n)) — uses the EMA of the EMA as a lag-correction term, producing a line that stays closer to price action and signals trend changes faster than standard EMA or SMA.
How do I add DEMA in TradingView?
Open any chart, click the Indicators button (the fx icon), and search for "Double EMA" or "DEMA". You will find "Double Exponential Moving Average (EMA)" under the Built-in category. Click it to add it to your chart. Click the gear icon next to the indicator name to adjust the period, source, or style.
Is DEMA better than EMA?
DEMA reacts faster than EMA because it removes more lag, making it potentially useful for short-term trading and early trend detection. However, the extra responsiveness also produces more false signals in choppy or range-bound markets. DEMA is often used by active traders; long-term investors frequently prefer the smoother signals of standard EMA or SMA. Neither is universally better — the right choice depends on your trading style and market conditions.
What is the best DEMA period for day trading?
There is no universally optimal period. Common starting points for day trading include 5, 9, and 21. Shorter periods like 5 or 9 track price closely and give quicker signals; longer periods like 21 filter more noise. Many traders use two DEMAs together — for example, DEMA(9) and DEMA(21) — and observe the crossovers. Always backtest any period setting on your specific instrument and timeframe before using it with real capital.
Does TradingView have a built-in DEMA indicator?
Yes. TradingView includes DEMA as a built-in indicator under the name "Double Exponential Moving Average (EMA)". No script installation is needed. You can also reference it in Pine Script using the ta.dema() function — see the TradingView Pine Script Reference for current syntax.
What is the difference between DEMA and TEMA?
DEMA uses two layers of exponential smoothing (2 × EMA − EMA of EMA). TEMA (Triple Exponential Moving Average) adds a third layer for even less lag. TEMA signals arrive faster but at the cost of greater noise sensitivity. Both were introduced by Patrick Mulloy in the same 1994 publication.
Can DEMA be used for forex and crypto trading?
Yes. DEMA works on any market with sufficient price history and liquidity — stocks, forex, crypto, futures, and indices. Note that crypto markets trade 24/7, while forex is generally 24/5. In fast-moving markets, DEMA's responsiveness can be useful for catching rapid trend shifts, but higher volatility also increases the risk of false signals.
Does DEMA repaint in TradingView?
Standard DEMA — calculated on fully closed historical bars — does not repaint past values. However, the value on the current, still-open bar will change as price moves, because the bar has not yet closed. Once a bar closes, its DEMA value is fixed. This is normal behavior for any EMA-based indicator, not a flaw specific to DEMA.
What are the main risks of using DEMA?
The main risks are: (1) whipsaws — in choppy markets, DEMA's sensitivity generates frequent false signals; (2) overconfidence in speed — faster signals are not inherently more accurate; (3) curve-fitting — optimizing the period to historical data often fails in live markets; and (4) insufficient confirmation — using DEMA as a sole decision tool ignores volume, momentum, market structure, and broader trend context. Always combine DEMA with other tools and defined risk management rules.
Sources
- TradingView Help Center, "Double Exponential Moving Average (EMA)" — tradingview.com
- TradingView Pine Script v5 Reference Manual — tradingview.com/pine-script-reference/v5
- StockCharts ChartSchool, "Double Exponential Moving Average (DEMA)" — stockcharts.com
- Investopedia, "Double Exponential Moving Average (DEMA) Formula" — investopedia.com
- Corporate Finance Institute, "Double Exponential Moving Average (DEMA)" — corporatefinanceinstitute.com
- Mulloy, P. G. (1994). "Smoothing Data with Faster Moving Averages." Technical Analysis of Stocks & Commodities, 1994.