Trend Momentum ColorWave

A custom indicator created by James Chambers 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 Trend Momentum ColorWave indicator

The Trend Momentum ColorWave leverages the strengths of both the MACD's momentum tracking and the SuperTrend's trend-following abilities, offering traders an immediate visual cue to the prevailing market sentiment and potential shifts in trends. This indicator is particularly useful for traders looking to enhance their chart analysis with an easy-to-interpret visual tool that combines trend and momentum insights for making informed trading decisions.

Source code

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

describe_indicator('Trend Momentum ColorWave');

// MACD components
const fastLength = input.number('Fast Length', 12);
const slowLength = input.number('Slow Length', 26);
const signalSmoothing = input.number('Signal Smoothing', 9);

const fastMA = ema(close, fastLength);
const slowMA = ema(close, slowLength);
const macdLine = sub(fastMA, slowMA);
const signalLine = sma(macdLine, signalSmoothing);

// Supertrend calculation
const superTrendLength = input.number('Supertrend Length', 14);
const superTrendMultiplier = input.number('Supertrend Multiplier', 3);
const superTrendValues = supertrend(superTrendLength, superTrendMultiplier);

// Iterate over each candle to determine its color
const candleColors = for_every(close, macdLine, signalLine, superTrendValues, (myPrice, myMacd, mySignal, mySuperTrend) => {
    if (myPrice > mySuperTrend && myMacd > mySignal) {
        return 'green'; // Price above Supertrend and MACD above signal
    } else if (myPrice < mySuperTrend && myMacd < mySignal) {
        return 'red'; // Price below Supertrend and MACD below signal
    } else if (myPrice < mySuperTrend && myMacd > mySignal) {
        return 'orange'; // Price below Supertrend but MACD above signal
    } else if (myPrice > mySuperTrend && myMacd < mySignal) {
        return 'purple'; // Price above Supertrend but MACD below signal
    } else {
        return 'blue'; // Neutral or unclassified state
    }
});

// Applying the color to candles
color_candles(candleColors);

// Register signals for each candle color
register_signal(for_every(candleColors, _color => _color === 'green'), 'Green Candle');
register_signal(for_every(candleColors, _color => _color === 'red'), 'Red Candle');
register_signal(for_every(candleColors, _color => _color === 'orange'), 'Orange Candle');
register_signal(for_every(candleColors, _color => _color === 'purple'), 'Purple Candle');
register_signal(for_every(candleColors, _color => _color === 'blue'), 'Blue Candle');