RSI, MACD Confluence

A custom indicator created by TrendSpider Team on TrendSpider. You can import this custom indicator into your TrendSpider account. Don't have TrendSpider? Create an account first, then import the custom indicator.

Chart featuring the RSI, MACD Confluence indicator

This indicator combines the Relative Strength Index (RSI) and MACD to identify moments of confluence between momentum and trend strength, visualized with colored candles:

Green (#2fcc56): Strong bullish confluence (RSI > 50 and MACD line above Signal line).

Light Gray: Partial alignment (one condition met).

Red: Bearish confluence (neither condition met).

This tool helps traders quickly spot alignment between two popular technical indicators, highlighting potential high-confidence trade setups."

Source code

This indicator had been implemented by TrendSpider Team in JavaScript on TrendSpider. Check out the developer documentation to learn more about JS on TrendSpider.

describe_indicator('RSI, MACD Confluence');

// Input parameters
const rsiLength = input.number('RSI Length', 14, { min: 1 });
const macdFastLength = input.number('MACD Fast Length', 12, { min: 1 });
const macdSlowLength = input.number('MACD Slow Length', 26, { min: 1 });
const macdSignalLength = input.number('MACD Signal Length', 9, { min: 1 });

// Calculate RSI
const myRsi = rsi(close, rsiLength);

// Calculate MACD
const myMacdLine = sub(ema(close, macdFastLength), ema(close, macdSlowLength));
const mySignalLine = ema(myMacdLine, macdSignalLength);
const myHistogram = sub(myMacdLine, mySignalLine);

// Define conditions
const rsiCondition = for_every(myRsi, r => r > 50);
const macdOverSignalCondition = for_every(myMacdLine, mySignalLine, (m, s) => m > s);

// Combine conditions and determine candle colors
const candleColors = for_every(
    rsiCondition,
    macdOverSignalCondition,
    (rsi, macdSignal) => {
        const trueCount = [rsi, macdSignal].filter(Boolean).length;
        if (trueCount === 2) return '#2fcc56';
        if (trueCount > 0) return 'lightgray';
        return 'red';
    }
);

// Color the candles
color_candles(candleColors);

// Register signals for scanner and strategy tester
register_signal(
    for_every(candleColors, c => c === '#2fcc56'),
    "Strong Bullish (Green)"
);

register_signal(
    for_every(candleColors, c => c === 'lightgray'),
    "Neutral (Gray)"
);

register_signal(
    for_every(candleColors, c => c === 'red'),
    "Bearish (Red)"
);