macd_test
Mar 4, 2019

The macd_test indicator is a trend-following strategy tool that utilizes the MACD oscillator and EMA crossovers to identify potential entry and exit points in trending markets.
Usage
The Usage section focuses on interpreting the trend signals generated by the interaction between the MACD components and price action.
- Long Entries: Occur when the MACD line is below zero, price action is lower than previous significant levels, and the MACD signal shows increasing momentum (diverging from previous lows).
- Short Entries: Occur when the MACD line is above zero, price action is higher than previous significant levels, and the MACD signal shows decreasing momentum.
- Exits: Positions are closed when the MACD histogram changes polarity (crossing the zero line) or when an opposing crossover/crossunder occurs.
Details
The script executes calculations based on standard Moving Average Convergence Divergence (MACD) parameters (12, 26, 7). It introduces a secondary EMA (9-period) to track price trends and determine relative price levels during crossovers.
The logic tracks specific price levels (crossOverPrice, crossUnderPrice) and signal levels (crossOverSignal, crossUnderSignal) at the moment of MACD crossovers. These values are used as thresholds for entry confirmation. Specifically, it looks for situations where the MACD signal strengthens while the price remains relatively favorable compared to its recent historical state at previous crossovers.
Settings
As a strategy script, this tool relies on fixed calculation parameters within the code. The primary variables affecting the output include:
- MACD Fast/Slow Lengths: Fixed at 12 and 26 periods for trend detection.
- Signal Smoothing: Fixed at 7 periods using an EMA.
- Price EMA: A 9-period EMA used to benchmark the price at signal points.
- Strategy Parameters: Includes default settings for 100% equity allocation and specific commission percentages (0.00075%).
FAQ
How do I use the signals from the macd_test indicator?
The indicator plots signals directly on the chart based on the strategy logic. Blue labels (B) represent long entries, while red labels (S) represent short entries.
What timeframes are best for this strategy?
The strategy uses standard MACD settings, which are versatile but typically perform best on mid-to-high timeframes where trends are more established.
How can I access the macd_test?
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.