Indicator · Pine Script v5 · On the chart

Multi MA Crossover Alerts

by g-moe· code credited to goodgains

This indicator plots four simple moving averages of periods 5, 10, 20, and 50 on the price chart.

View on GitHub

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code162
Settings0inputs
LicenceNone statedfile: MPL-2.0
Last update5 months ago27 May 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

162 lines of Pine Script v5 from Tradingview/multi-ma-crossover-alerts.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

multi-ma-crossover-alerts.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © goodgains


//@version=5
indicator("Multi MA Crossover Alerts", overlay = true)

// @keywords: four-sma-overlay, ma5-ma10-ma20-ma50, pairwise-crossover-alerts, crossunder-alerts, close-ma-cross-alerts, aggregate-cross-alert, sixteen-pair-combinations, alertcondition-library, moving-average-stack, bullish-cross-messages, bearish-cross-messages, any-line-cross-bundle, close-cross-bundle, multi-ma-watch, crossover-notification, ma-intersection-monitor, trend-alignment-alerts, sma-period-set, passive-alert-only, no-signal-plots


ma5 = ta.sma(close, 5)
ma10 = ta.sma(close, 10)
ma20 = ta.sma(close, 20)
ma50 = ta.sma(close, 50)

ma5_plot = plot(ma5, title = 'MA 5', color = color.white)
ma10_plot = plot(ma10, title = 'MA 10', color = color.aqua)
ma20_plot = plot(ma20, title = 'MA 20', color = color.orange)
ma50_plot = plot(ma50, title = 'MA 50', color = color.yellow)




// # lines crossing each other above
ma5_crossabove_ma10 = ta.crossover(ma5, ma10)
ma5_crossabove_ma20 = ta.crossover(ma5, ma20)
ma5_crossabove_ma50 = ta.crossover(ma5, ma50)

ma10_crossabove_ma5 = ta.crossover(ma10, ma5)
ma10_crossabove_ma20 = ta.crossover(ma10, ma20)
ma10_crossabove_ma50 = ta.crossover(ma10, ma50)

ma20_crossabove_ma5 = ta.crossover(ma20, ma5)
ma20_crossabove_ma10 = ta.crossover(ma20, ma10)
ma20_crossabove_ma50 = ta.crossover(ma20, ma50)

ma50_crossabove_ma5 = ta.crossover(ma50, ma5)
ma50_crossabove_ma10 = ta.crossover(ma50, ma10)
ma50_crossabove_ma20 = ta.crossover(ma50, ma20)

alertcondition(ma5_crossabove_ma10, title = 'MA5 Cross Above MA10', message = 'MA5 Cross Above MA10')
alertcondition(ma5_crossabove_ma20, title = 'MA5 Cross Above MA20', message = 'MA5 Cross Above MA20')
alertcondition(ma5_crossabove_ma50, title = 'MA5 Cross Above MA50', message = 'MA5 Cross Above MA50')

alertcondition(ma10_crossabove_ma5, title = 'MA10 Cross Above MA5', message = 'MA10 Cross Above MA5')
alertcondition(ma10_crossabove_ma20, title = 'MA10 Cross Above MA20', message = 'MA10 Cross Above MA20')
alertcondition(ma10_crossabove_ma50, title = 'MA10 Cross Above MA50', message = 'MA10 Cross Above MA50')

alertcondition(ma20_crossabove_ma5, title = 'MA20 Cross Above MA5', message = 'MA20 Cross Above MA5')
alertcondition(ma20_crossabove_ma10, title = 'MA20 Cross Above MA10', message = 'MA20 Cross Above MA10')
alertcondition(ma20_crossabove_ma50, title = 'MA20 Cross Above MA50', message = 'MA20 Cross Above MA50')

alertcondition(ma50_crossabove_ma5, title = 'MA50 Cross Above MA5', message = 'MA50 Cross Above MA5')
alertcondition(ma50_crossabove_ma10, title = 'MA50 Cross Above MA10', message = 'MA50 Cross Above MA10')
alertcondition(ma50_crossabove_ma20, title = 'MA50 Cross Above MA20', message = 'MA50 Cross Above MA20')


// # lines crossing each other below
ma5_crossbelow_ma10 = ta.crossunder(ma5, ma10)
ma5_crossbelow_ma20 = ta.crossunder(ma5, ma20)
ma5_crossbelow_ma50 = ta.crossunder(ma5, ma50)

ma10_crossbelow_ma5 = ta.crossunder(ma10, ma5)
ma10_crossbelow_ma20 = ta.crossunder(ma10, ma20)
ma10_crossbelow_ma50 = ta.crossunder(ma10, ma50)

ma20_crossbelow_ma5 = ta.crossunder(ma20, ma5)
ma20_crossbelow_ma10 = ta.crossunder(ma20, ma10)
ma20_crossbelow_ma50 = ta.crossunder(ma20, ma50)

ma50_crossbelow_ma5 = ta.crossunder(ma50, ma5)
ma50_crossbelow_ma10 = ta.crossunder(ma50, ma10)
ma50_crossbelow_ma20 = ta.crossunder(ma50, ma20)

alertcondition(ma5_crossbelow_ma10, title = 'MA5 Cross Below MA10', message = 'MA5 Cross Below MA10')
alertcondition(ma5_crossbelow_ma20, title = 'MA5 Cross Below MA20', message = 'MA5 Cross Below MA20')
alertcondition(ma5_crossbelow_ma50, title = 'MA5 Cross Below MA50', message = 'MA5 Cross Below MA50')

alertcondition(ma10_crossbelow_ma5, title = 'MA10 Cross Below MA5', message = 'MA10 Cross Below MA5')
alertcondition(ma10_crossbelow_ma20, title = 'MA10 Cross Below MA20', message = 'MA10 Cross Below MA20')
alertcondition(ma10_crossbelow_ma50, title = 'MA10 Cross Below M50', message = 'MA10 Cross Below MA50')

alertcondition(ma20_crossbelow_ma5, title = 'MA20 Cross Below MA5', message = 'MA20 Cross Below MA5')
alertcondition(ma20_crossbelow_ma10, title = 'MA20 Cross Below MA10', message = 'MA20 Cross Below MA10')
alertcondition(ma20_crossbelow_ma50, title = 'MA20 Cross Below MA50', message = 'MA20 Cross Below MA50')

alertcondition(ma50_crossbelow_ma5, title = 'MA50 Cross Below MA5', message = 'MA50 Cross Below MA5')
alertcondition(ma50_crossbelow_ma10, title = 'MA50 Cross Below MA10', message = 'MA50 Cross Below MA10')
alertcondition(ma50_crossbelow_ma20, title = 'MA50 Cross Below MA20', message = 'MA50 Cross Below MA20')


any_line_crossing_above_line = 
   ma5_crossabove_ma10
 or ma5_crossabove_ma20
 or ma5_crossabove_ma50

 or ma10_crossabove_ma5
 or ma10_crossabove_ma20
 or ma10_crossabove_ma50

 or ma20_crossabove_ma5
 or ma20_crossabove_ma10
 or ma20_crossabove_ma50

 or ma50_crossabove_ma5
 or ma50_crossabove_ma10
 or ma50_crossabove_ma20
alertcondition(any_line_crossing_above_line, title = 'ANY - Line Crossing Above Another Line', message = 'Any Line Crossing Above Another Line')


any_line_crossing_below_line = 
   ma5_crossbelow_ma10
 or ma5_crossbelow_ma20
 or ma5_crossbelow_ma50

 or ma10_crossbelow_ma5
 or ma10_crossbelow_ma20
 or ma10_crossbelow_ma50

 or ma20_crossbelow_ma5
 or ma20_crossbelow_ma10
 or ma20_crossbelow_ma50

 or ma50_crossbelow_ma5
 or ma50_crossbelow_ma10
 or ma50_crossbelow_ma20
alertcondition(any_line_crossing_below_line, title = 'ANY - Line Crossing Below Another Line', message = 'Any Line Crossing Below Another Line')


// # close crossing above
close_above_ma5 = ta.crossover(close, ma5)
close_above_ma10 = ta.crossover(close, ma10)
close_above_ma20 = ta.crossover(close, ma20)
close_above_ma50 = ta.crossover(close, ma50)
alertcondition(close_above_ma5, title = 'Close Cross Above MA5', message = 'Close Cross Above MA5')
alertcondition(close_above_ma10, title = 'Close Cross Above MA10', message = 'Close Cross Above MA10')
alertcondition(close_above_ma20, title = 'Close Cross Above MA20', message = 'Close Cross Above MA20')
alertcondition(close_above_ma50, title = 'Close Cross Above MA50', message = 'Close Cross Above MA50')

close_above_any = 
 close_above_ma5 
 or close_above_ma10
 or close_above_ma20 
 or close_above_ma50
alertcondition(close_above_any, title = 'ANY - Close Crosses Above Any Line', message = 'Close Crosses Above ANY Line')

// # close crossing below
close_below_ma5 = ta.crossunder(close, ma5)
close_below_ma10 = ta.crossunder(close, ma10)
close_below_ma20 = ta.crossunder(close, ma20)
close_below_ma50 = ta.crossunder(close, ma50)
alertcondition(close_below_ma5, title = 'Close Cross Below MA5', message = 'Close Cross Below MA5')
alertcondition(close_below_ma10, title = 'Close Cross Below MA10', message = 'Close Cross Below MA10')
alertcondition(close_below_ma20, title = 'Close Cross Below MA20', message = 'Close Cross Below MA20')
alertcondition(close_below_ma50, title = 'Close Cross Below MA50', message = 'Close Cross Below MA50')

close_below_any = 
 close_below_ma5 
 or close_below_ma10
 or close_below_ma20 
 or close_below_ma50
alertcondition(close_above_any, title = 'ANY - Close Crosses Below Any Line', message = 'Close Crosses Below ANY Line')

Overview

Multi MA Crossover Alerts calculates and sends alert conditions for every pairwise crossover and crossunder between the moving averages, including MA5 cross above MA10, MA10 cross above MA5, and all other ordered combinations. These alerts monitor trend changes and alignment across the moving average stack. The script draws the moving averages directly on the price chart.

Details

Published by

g-moe on GitHub

Code credit

goodgains, as written in the script's header

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

947 stars

The Adaptive Laguerre Filter calculates a smoothed, dynamically adjusted trendline plotted directly on the main price chart. It dynamically adjusts its damping factor (alpha) based on recent price range variations and median percentile calculations over a spec

Indicator v4 TrendMoving averages
Updated 12 days ago · GPL-3.0 GitHub repository of Adaptive Laguerre Filter
330 stars

This script plots three moving averages on the price chart: a fast EMA or SMA with 10 periods, a slow EMA or SMA with 20 periods, and a trend EMA or SMA with 100 periods. It signals trend changes by drawing a white cross when the fast moving average crosses ab

Indicator v4 TrendMoving averages
Updated 2 months ago · None stated GitHub repository of 3 EMA/SMA + Cross [Alorse]
318 stars

This indicator plots four customizable moving averages directly on the main price chart using default lengths of 3, 8, 21, and 50 periods. It fills the space between adjacent averages in green or maroon depending on trend alignment. Additionally, it computes B

Indicator v5 Moving averagesTrend
Updated 2 months ago · MIT GitHub repository of Multiple Moving Averages

NVDA Trend Ribbon

by longsurf-ai
280 stars

This indicator plots three exponential moving averages and ATR volatility envelopes on the price chart. It compares the fast and slow EMAs to shade a trend ribbon and marks confirmed upward and downward crossovers with triangle labels. Settings change the thre

Indicator v6 TrendMoving averages
Updated 3 days ago · MIT GitHub repository of NVDA Trend Ribbon
257 stars

Donald SPX - Options Trading is an overlay indicator designed for intraday SPX analysis. It plots a 200-period Weighted Moving Average (WMA) on the price chart while evaluating multi-timeframe market structure across Daily, 15-minute, 5-minute, and 2-minute ba

Indicator v5 Moving averagesTrend Repaints
Updated 7 weeks ago · None stated GitHub repository of Donald SPX - Options Trading
228 stars

This indicator computes moving average and RSI bias signals across the current timeframe and four higher timeframes. It sums biases from the MA and RSI to derive an overall bullish or bearish signal. The results appear in a configurable table that displays eac

Indicator v6 TrendMoving averages
Updated 3 months ago · None stated GitHub repository of Multi-Timeframe Analysis Template

More Moving averages scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers