All indicators

Stochastic MACD

May 23, 2022

Static chart image
SignalsOscillatorsMoving Averages

The Stochastic MACD indicator is an oscillating momentum tool that transforms traditional Moving Average Convergence Divergence (MACD) components through a stochastic calculation to provide standardized levels for better historical comparison. By applying a stochastic oscillator to the moving averages, this tool allows traders to identify momentum shifts and trend reversals while maintaining a consistent scale.

Usage

The Usage section describes how the script can be used in various market conditions:

  • Trend Identification: Like the standard MACD, the relationship between the SMACD line and the Signal line indicates the current momentum. When the SMACD line is above the Signal line, bullish momentum is present.
  • Mean Reversion: Because the values are passed through a stochastic formula, the indicator oscillates within a more predictable range. Traders can use the provided overbought (15) and oversold (-15) levels to identify potential exhaustion points in a trend.
  • Histogram Analysis: The color-coded histogram helps visualize the strength of the momentum. A rising histogram above zero (bright green) indicates strengthening bullish momentum, while a falling histogram below zero (bright red) suggests strengthening bearish momentum.

Details

The Stochastic MACD is constructed by first calculating the Fast and Slow Exponential Moving Averages (EMAs). Instead of simply subtracting these values as a standard MACD does, each EMA is individually processed through a stochastic function based on a user-defined lookback period.

The SMACD line is the difference between these two stochastic values. A signal line (EMA of the SMACD) is then applied to provide crossover triggers. This implementation solves one of the primary limitations of the standard MACD: the lack of a fixed scale. By using stochastics, the absolute levels of the indicator can be more accurately compared against historical peaks and troughs regardless of the asset's price level.

Settings

  • Fast Length: The period for the shorter-term exponential moving average.
  • Slow Length: The period for the longer-term exponential moving average.
  • Signal Length: The smoothing period used to calculate the Signal line from the SMACD line.
  • Stochastic Lookback: The lookback window used for the stochastic transformation of the moving averages.
  • Color Lookback: Determines the number of bars used to calculate if the histogram is rising or falling for color transitions. Setting this to 0 disables gradient coloring.
  • Histogram Colors: Allows customization of the colors for positive rising, positive falling, negative rising, and negative falling histogram bars.

FAQ

How do I interpret the Stochastic MACD crossovers?

A bullish crossover occurs when the blue SMACD line crosses above the Signal line, often used as a signal for potential upward momentum. Conversely, a bearish crossunder occurs when the SMACD line falls below the Signal line.

How does this differ from a regular MACD?

While a regular MACD uses raw price differences which vary based on the asset's price, the Stochastic MACD standardizes these movements using a stochastic lookback, making it easier to identify extreme momentum levels.

How can I access the Stochastic MACD?

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.