Moving Average Crossover

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

Chart featuring the Moving Average Crossover indicator

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 Crossover');
const ma = sma(close, 100);
const crossoverLabels = for_every(close, ma, shift(close, 1), shift(ma, 1), (c, m, pc, pm) => {
    if ((c > m) != (pc > pm)) {
        return `ma cross @${c}`;
    }
});
paint(crossoverLabels, { style: 'labels_above', color: 'red', backgroundBorderRadius: 14, verticalOffset: -2, backgroundColor: 'orange' });