All indicators

EMA Cross + Divergence strategy

Dec 17, 2021

Static chart image
SignalsDivergencesMoving Averages

The EMA Cross + Divergence strategy tool is a sample strategy designed to demonstrate how to integrate external divergence signals into a trend-following framework for automated or backtested trading.

Usage

The strategy combines Exponential Moving Average (EMA) crossovers with divergence signals to filter for high-probability entries. A long entry is triggered when the fast EMA crosses above the slow EMA, provided a regular bullish divergence has been detected within a specific lookback period. Conversely, a short entry is triggered when the fast EMA crosses below the slow EMA following a recent regular bearish divergence.

To use this strategy:

  1. Add a compatible divergence indicator (such as The Divergent Pro) to your chart.
  2. In the strategy settings, use the "The Divergent: Divergence Signal" input source to select the divergence output from the external indicator.
  3. The strategy will then process these signals to validate EMA crossovers.

Details

This script utilizes a specialized library to handle the synchronization and processing of external source signals. By using a library-based initialization, the script ensures that signal processing is efficient and consistent across different bars. The strategy logic includes a lookback mechanism (defaulting to 10 bars) that checks for the presence of a divergence signal shortly before or during the EMA crossover, ensuring the trend change is supported by momentum exhaustion or accumulation.

Settings

The Divergent

  • The Divergent: Divergence Signal: Source input used to link the external indicator's divergence signals to the strategy.

EMA Settings

  • Fast EMA Length: The period used for the faster-moving exponential average (e.g., 20).
  • Slow EMA Length: The period used for the slower-moving exponential average (e.g., 40).

Position Settings

  • Take Profit %: The percentage gain from the entry price at which the position will close for a profit.
  • Stop Loss %: The percentage loss from the entry price at which the position will close to limit risk.

FAQ

How do I access EMA Cross + Divergence strategy?

You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.

Can I use this with any divergence indicator?

The strategy is designed to work with indicators that output specific numeric codes for divergences through the source input, specifically optimized for use with The Divergent series.

Is this strategy ready for live trading?

This script is provided as a sample demonstration of how to consume external signals and should be thoroughly backtested and optimized for specific markets before any live application.

Free indicator

Get free access to this indicator on the platforms below.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.