EMA Divergence
Feb 17, 2019

The EMA Divergence indicator calculates the distance between price and a selected moving average or VWAP to identify potential overextension and pullback opportunities.
Usage
The indicator can be used to spot mean reversion or trend exhaustion points by visualizing how far price has deviated from its baseline. It plots an area chart that changes color based on user-defined thresholds:
- Lime: Price is within the normal range (below the minimum threshold).
- Yellow: Price has reached the first threshold (Min Band), indicating a potential overextension.
- Red: Price has exceeded the second threshold (Max Band), suggesting extreme divergence.
Users can toggle between viewing this divergence as a percentage or in absolute currency values. The "Divergence for Pullback" mode allows for a specialized calculation comparing multiple EMA and VWAP relationships to better time entries during pullbacks.
Details
The script functions by calculating the difference between the current price and an Exponential Moving Average (EMA) or Volume Weighted Average Price (VWAP). If the EMA period is set to 0, the script defaults to using VWAP as the baseline.
The implementation includes an "Absolute values" toggle; when enabled, the indicator only shows the magnitude of the distance. When disabled, it shows both positive and negative divergence, allowing traders to distinguish between bullish and bearish overextensions. The "Last only" feature helps clean up charts by only displaying the most recent data point's status.
Settings
- EMA Periods / 0 for VWAP: Sets the period for the EMA calculation. Setting this to 0 switches the baseline to VWAP.
- Min Band %: The first threshold for divergence. When price exceeds this, the plot turns yellow.
- Max Band %: The second threshold for divergence. When price exceeds this, the plot turns red.
- Absolute values: When checked, the indicator treats all divergence as positive values.
- Last only: When enabled, the indicator only plots the most recent calculation.
- Values in $: Switches the Y-axis and calculation logic from percentage-based to absolute currency values based on the daily open.
- Divergence for Pullback: Activates a multi-timeframe comparison logic to identify specific pullback setups.
FAQ
How do I use EMA Divergence?
You can use it to identify when price is too far from its average, which often precedes a reversion to the mean or a temporary consolidation.
Can I use this for VWAP instead of EMA?
Yes, simply set the "EMA Periods" input to 0, and the script will automatically use VWAP as the reference point for calculations.
How can I access EMA Divergence?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.