Skip to content

Indicator Releases

First Release: Dual-Speed EMA + MACD Cycle Strategy

Not financial advice. Backtested performance does not predict future results. See our risk disclosure.

TL;DR

  • Function: Combines a fast/slow Exponential Moving Average (EMA) crossover with Moving Average Convergence Divergence (MACD) cycle alignment.
  • Target Market/Timeframe: Designed for trend-persistent regimes (e.g., higher-timeframe forex, crypto, or equities; 1H to Daily).
  • Key Edge: Attempts to reduce whipsaw in ranging markets by requiring directional momentum (MACD) to validate structural trend shifts (EMA).

Not financial advice. Backtested performance does not predict future results.

Context and Thesis

Pure trend-following systems, particularly those reliant on moving average crossovers, systematically underperform during mean-reverting or ranging market regimes. The primary inefficiency this framework targets is the "false breakout"—a structural price shift that lacks the underlying momentum to sustain a new trend.

By pairing a dual-speed EMA with an MACD oscillator, the logic introduces a secondary validation layer. The EMA crossover dictates the baseline structural trend, while the MACD acts as a momentum filter. This is a defensive heuristic: it sacrifices early entry (accepting increased lag) in exchange for higher signal fidelity.

Methodology

The underlying logic relies on synchronous state conditions rather than isolated events:

  1. Trend State: Evaluates the relationship between a Fast EMA and a Slow EMA. A bullish state requires the Fast EMA to be strictly greater than the Slow EMA.
  2. Momentum State: Evaluates the standard MACD line relative to its Signal line. A bullish momentum state requires the MACD line to be strictly greater than the Signal line.
  3. Entry Logic: A long position is triggered only when both the Trend State and Momentum State are aligned bullishly. Short entries require the inverse (bearish alignment of both).
  4. Limitations: Because both indicators are derivatives of historical price, the system suffers from inherent lag. In a high-volatility, range-bound environment, the strategy will inevitably trigger late entries and late exits, resulting in whipsaw losses.

Pine Script v6 Implementation

Below is the raw logic translated into TradingView's Pine Script v6. This code is generated by AlgoNexta for research and structural validation.

//@version=6
strategy("Dual-Speed EMA + MACD Cycle Strategy", overlay=true, margin_long=100, margin_short=100)

// --- Inputs ---
var int fast_ema_len = input.int(12, title="Fast EMA Length")
var int slow_ema_len = input.int(26, title="Slow EMA Length")
var int macd_fast    = input.int(12, title="MACD Fast Length")
var int macd_slow    = input.int(26, title="MACD Slow Length")
var int macd_signal  = input.int(9,  title="MACD Signal Length")

// --- Core Calculations ---
float fast_ema = ta.ema(close, fast_ema_len)
float slow_ema = ta.ema(close, slow_ema_len)

[macd_line, signal_line, _] = ta.macd(close, macd_fast, macd_slow, macd_signal)

// --- State Logic ---
bool is_ema_bullish = fast_ema > slow_ema
bool is_ema_bearish = fast_ema < slow_ema

bool is_macd_bullish = macd_line > signal_line
bool is_macd_bearish = macd_line < signal_line

// --- Execution ---
if (is_ema_bullish and is_macd_bullish)
    strategy.entry("Long", strategy.long)

if (is_ema_bearish and is_macd_bearish)
    strategy.entry("Short", strategy.short)

Backtest Results

Note: AlgoNexta requires rigorous statistical evidence for performance claims. At the time of this release, comprehensive backtest data and Vision grading are pending.

  • Sample Size: N/A (Pending)
  • Date Range: N/A (Pending)
  • Validation: N/A. No in-sample or walk-forward data has been supplied for this specific parameter set. Do not deploy this script to live capital without conducting your own parameter optimization and out-of-sample validation.

Key Takeaways

  • Dual-Filter Logic: Use the EMA for baseline trend direction and the MACD to confirm momentum.
  • Parameter Sensitivity: Default inputs (12/26/9) are standard starting points, not optimized parameters. Quants must tune these inputs for their specific asset class to appropriately map the script to actual market volatility.
  • Evidence Pending: Treat this script strictly as a baseline educational scaffold until you have generated statistically significant backtest results on your target instruments.

Risk Disclosure

Algorithmic trading involves substantial risk of loss and is not suitable for all investors. The strategies, scripts, and backtests presented are for educational and research purposes only. Past performance, whether in-sample or out-of-sample, does not guarantee future returns. Systems may fail due to changes in market regimes, liquidity constraints, or execution slippage. Always conduct rigorous independent validation, including walk-forward testing in simulated environments, before allocating live capital. This material does not constitute financial or investment advice.

Educational and research content. Not financial advice. Trading involves substantial risk of loss.

Explore more

Browse the indicator library

View indicators

We use cookies to understand how the site is used and improve it. We only load analytics after you accept. Privacy Policy

Dual-Speed EMA & MACD Strategy Code | AlgoNexta