All indicators

MACD+RSI+Flag v2

Aug 22, 2021

Static chart image
SignalsOscillatorsDivergencesMoving Averages

The MACD+RSI+Flag v2 indicator combines two of the most popular momentum oscillators into a single pane to help traders identify trend changes, overbought/oversold conditions, and divergence signals simultaneously.

Usage

The script is designed to provide a comprehensive view of momentum by overlaying the MACD and a scaled RSI. Users can identify potential entries using several visual cues:

  • MACD Crossings: Diamonds appear at the top or bottom of the pane when the MACD line crosses the signal line, indicating potential momentum shifts.
  • RSI Flags: Triangle shapes appear when the price changes direction (first green candle after red or vice versa) while the RSI is in extreme overbought or oversold territory.
  • Divergence Labels: The tool automatically detects and labels Regular and Hidden Bullish/Bearish divergences between price and the RSI oscillator, highlighting potential trend exhaustions or continuations.
  • Scaled RSI: Because MACD and RSI operate on different scales, the RSI is normalized via a "Plot Scale Factor" to ensure both indicators are clearly visible and comparable in the same window.

Details

The MACD (Moving Average Convergence Divergence) is calculated as the difference between a Fast and Slow moving average (defaulting to 12 and 26). The histogram represents the distance between the MACD line and its Signal line. The RSI (Relative Strength Index) measures the velocity and magnitude of price movements. In this version, the RSI is adjusted by a scale factor so it fits within the typical range of the MACD values for the specific asset being traded. Divergence logic uses pivot lookbacks to compare price peaks/valleys with oscillator peaks/valleys, providing automated technical analysis.

Settings

MACD Inputs

  • MACD Fast Length: The period for the shorter moving average.
  • MACD Slow Length: The period for the longer moving average.
  • Signal Smoothing: The smoothing period for the MACD signal line.
  • Oscillator/Signal MA Type: Choice between SMA or EMA for calculations.

RSI Inputs

  • RSI Length: The lookback period for RSI calculation.
  • OverSold/OverBought RSI%: Thresholds for extreme conditions (e.g., .3 for 30% and .7 for 70%).
  • Plot Scale Factor RSI: Adjusts the RSI height to match the MACD range of the current symbol.
  • Flag and Text os/ob RSI: Toggles for visual triangle markers and "OS Call / OB Put" text.

Divergence Inputs

  • Pivot Lookback Right/Left: Sets the number of bars required to confirm a pivot point.
  • Max/Min of Lookback Range: Defines the search window for finding previous pivots.
  • Plot Bullish/Bearish/Hidden: Toggles for displaying different types of divergence labels.

FAQ

How do I align the RSI with the MACD?

You can use the "Plot Scale Factor RSI" setting. Since different assets (like Forex vs. Crypto) have different MACD price ranges, adjusting this value will stretch or compress the RSI to fit the pane.

What do the triangles and diamonds represent?

Diamonds represent MACD signal line crossovers. Triangles (Flags) represent a candle color change occurring while the RSI is in an overbought or oversold state.

How can I access MACD+RSI+Flag v2?

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.