Moving Average Trend Identifier

A custom indicator created by TrendSpider 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 Moving Average Trend Identifier indicator

This indicator visually highlights price action by coloring candles based on their relationship to key moving averages (10, 20, 50, 100, and 200 SMAs). The color of each candle provides immediate insight into whether price momentum is decisively bullish, bearish, or neutral:

Green Candles: A candle is colored green when it both opens and closes above all the key moving averages, signaling strong bullish momentum and clear upward dominance.

Red Candles: A candle is colored red when it both opens and closes below all the key moving averages, indicating strong bearish momentum and clear downward pressure.

Grey Candles: A candle is colored grey if it does not meet the criteria for either green or red. This reflects a lack of confluence in momentum, suggesting neutral or mixed conditions.

Source code

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

describe_indicator('Moving Average Trend Identifier');

// Define the key moving averages
const lengths = [10, 20, 50, 100, 200];
const mas = lengths.map(length => sma(close, length));

// Function to check if a value is above all MAs
const isAboveAll = (value, maValues) => maValues.every(ma => value > ma);

// Function to check if a value is below all MAs
const isBelowAll = (value, maValues) => maValues.every(ma => value < ma);

// Compute the candle colors
const candleColors = for_every(open, close, (o, c, _, i) => {
    const maValues = mas.map(ma => ma[i]);
    if (isAboveAll(o, maValues) && isAboveAll(c, maValues)) {
        return '#2fcc56';
    } else if (isBelowAll(o, maValues) && isBelowAll(c, maValues)) {
        return 'red';
    } else {
        return 'grey';
    }
});

// Color the candles
color_candles(candleColors);

// Create signals for red, green, and grey candles
const greenSignal = for_every(candleColors, color => color === '#2fcc56' ? 1 : 0);
const redSignal = for_every(candleColors, color => color === 'red' ? 1 : 0);
const greySignal = for_every(candleColors, color => color === 'grey' ? 1 : 0);

register_signal(greenSignal, "Green Candle Signal");
register_signal(redSignal, "Red Candle Signal");
register_signal(greySignal, "Grey Candle Signal");