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' });