All indicators

MACD strategy + SuperTrend

Sep 22, 2022

Static chart image
SignalsOscillatorsMoving AveragesTrailing-StopVolatility

The MACD strategy + SuperTrend tool combines momentum-based MACD signals with trend-following filters and a trailing stop mechanism to help traders identify high-probability entries.

Usage

The indicator generates signals based on the interaction between the MACD and a long-term Exponential Moving Average (EMA).

  • Sell Signals: Occur when the MACD line crosses below the Signal line while the MACD is above the zero line and the price is below the 200 EMA. This indicates a bearish mean-reversion opportunity within a primary downtrend.
  • Buy Signals: Occur when the MACD line crosses above the Signal line while the MACD is below the zero line and the price is above the 200 EMA. This indicates a bullish mean-reversion opportunity within a primary uptrend.

The script also includes a trailing stop visual (red and green lines) calculated using the Average True Range (ATR). Traders can use these lines to define potential stop-loss levels. The background color highlights confirmed signal areas to improve chart readability.

Details

This script implements a trend-following framework using the 200 EMA as a primary trend filter. To further refine entries, it includes an optional noise filter that checks if the previous 14 candles stayed on the correct side of the EMA, ensuring the trend is established rather than volatile. The script also integrates SuperTrend logic, which can be toggled to act as the primary visual focus for those preferring volatility-based trend tracking alongside MACD momentum.

Settings

General

  • EMA Length: Sets the period for the trend-filtering Exponential Moving Average (default is 200).
  • Bullish/Bearish trend: Customizes the background colors for bullish and bearish signal confirmations.
  • EMA Filter?: When enabled, signals are only valid if none of the previous 14 candles closed on the opposite side of the EMA.
  • Background confirmation?: Toggles the visibility of the signal background highlights.
  • Only Supertrend?: Filters the trailing stop visibility based strictly on the SuperTrend direction.

ATR

  • ATR Multiplier: Adjusts the distance of the trailing stop from the price.
  • ATR Length: Sets the lookback period for the ATR calculation.

MACD

  • Fast/Slow Length: Periods for the short and long-term moving averages used in the MACD.
  • Source: The price source used for MACD calculations (default is Close).
  • Signal Smoothing: The period for the MACD Signal line.
  • MA Types: Allows selecting between SMA or EMA for both the oscillator and the signal line.

FAQ

How do I use the noise filter effectively?

The "EMA Filter" setting is designed to prevent entries during choppy price action. If the price has frequently crossed the EMA within the last 14 bars, the signal will be suppressed to avoid "fakeouts."

Does this indicator repaint?

The indicator does not repaint on historical bars once the candle has closed. It is recommended to use "Once Per Bar Close" for alerts to ensure the signal is confirmed.

How can I access this tool?

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.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

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