All indicators

Multiple Simple and Exp Moving Averages

Apr 8, 2018

Static chart image
SignalsMoving Averages

The Multiple Simple and Exp Moving Averages tool provides a consolidated interface to plot up to six customizable moving averages with independent settings for calculation type and timeframe.

Usage

The Usage section describes how the script can be used to analyze market trends and price momentum. Traders can utilize this tool to monitor multiple layers of support and resistance or identify trend reversals through moving average crossovers.

By default, the script plots six lines. Users can customize each line to be either a Simple Moving Average (SMA) or an Exponential Moving Average (EMA). For example, a trader might set the first three MAs as short-term EMAs (5, 10, 20) to track immediate price momentum, while setting the remaining three as long-term SMAs (50, 100, 200) to identify the broader market trend.

The Multi Timeframe (MTF) feature allows users to overlay moving averages from higher timeframes (such as Daily or Weekly) onto a lower timeframe chart (such as 15-minute or 1-hour). This helps in identifying whether short-term price action aligns with long-term structural trends without switching chart views.

Details

The script is constructed to be highly modular, allowing for independent control over each of the six moving average instances.

  • Calculation Logic: For each enabled MA, the script checks the "Exponential" toggle. If selected, it applies the EMA formula; otherwise, it applies the SMA formula.
  • Multi-Timeframe Execution: When the "Enable Multi Timeframe" option is active, the script utilizes the request.security function to fetch data from the specified timeframe. This data is then mapped onto the current chart.
  • Alert Integration: The script includes built-in alert conditions for crossovers and crossunders between the first two moving averages (MA 1 and MA 2), facilitating automated notifications for potential entry or exit points.

Settings

  • Source: Determines the price input used for all moving average calculations (e.g., Close, Open, High, Low).
  • Enable Multi Timeframe: A toggle that, when enabled, calculates all moving averages based on the timeframe specified in the "Time frame" input rather than the current chart timeframe.
  • Time frame: Defines the specific timeframe (e.g., Daily, 4-hour) used for calculations when the Multi Timeframe option is enabled.
  • Exponential MA [1-6]: A checkbox for each of the six moving averages. When checked, the script calculates an EMA; when unchecked, it calculates an SMA.
  • MA [1-6] Length: Sets the lookback period for each respective moving average. Setting a length to 1 effectively hides the line from the chart.

FAQ

Can I use different timeframes for each moving average? No, the multi-timeframe setting applies globally to all active moving averages when the "Enable Multi Timeframe" option is checked.

How do I disable a moving average I don't need? To disable or hide a specific moving average, set its corresponding "Length" input to 1 or uncheck its visibility in the script's style settings.

How can I access the Multiple Simple and Exp Moving Averages tool? 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.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.