Moving Averages With Cross Alerts
Apr 23, 2022

The Moving Averages With Cross Alerts indicator provides a versatile framework for plotting up to five customizable moving averages on a single chart with built-in alert functionality for various crossover and crossunder scenarios.
Usage
The Usage section describes how the script can be used, examples should be provided in this section. This tool is primarily used to identify trend direction and potential reversal points through the interaction of multiple timeframes. For example, a trader might enable a 50-period and a 200-period moving average to monitor for "Golden Cross" or "Death Cross" events.
Users can toggle individual lines on or off depending on their specific strategy requirements. By selecting different calculation methods (such as EMA for faster response or SMA for smoother data), the indicator adapts to different market conditions. The cross alerts can be configured to notify users when a shorter-term moving average crosses a longer-term one, signaling potential shifts in momentum.
Details
The script consolidates multiple moving average calculations into one efficient tool, supporting eight distinct types: Simple (SMA), Exponential (EMA), Hull (HMA), Running (RMA), Weighted (WMA), Volume Weighted (VWMA), Volume Weighted Average Price (VWAP), and Arnaud Legoux (ALMA).
The cross alert logic is pre-configured for several combinations (e.g., MA1 vs MA2, MA2 vs MA3, etc.), allowing for multi-layered trend analysis. This implementation uses a centralized calculation function to ensure consistency across all five lines and includes dynamic alert messaging that identifies whether a cross indicates a possible uptrend or downtrend.
Settings
- Moving Averages Type: Selects the mathematical method used for all enabled moving averages (SMA, EMA, HMA, RMA, WMA, VWMA, VWAP, or ALMA).
- MA1 - MA5 Groups:
- Enable: Toggles the visibility and calculation of the specific moving average.
- Source: Determines the price data used for calculation (e.g., Close, Open, High, Low).
- Length: Sets the number of bars used in the calculation period.
- Color: Customizes the line color for better visual distinction on the chart.
FAQ
How do I set up a specific crossover alert? You can access the Alert menu in your charting platform and select one of the many pre-defined conditions, such as "MA1 Cross Over MA2," to receive notifications when the lines intersect.
Can I use different moving average types for different lines? No, the script applies a global "Moving Averages Type" setting to all enabled lines to maintain consistency in trend analysis, though each line can have a unique length and source.
How do I get access to this indicator? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.