All indicators

Variety N-Tuple Moving Averages

Sep 5, 2022

Static chart image
Moving Averages

The Variety N-Tuple Moving Averages indicator allows users to create nested moving averages with a depth of up to 30, providing highly customized smoothing options for trend analysis.

Usage

The Usage section describes how the script can be used to generate specific moving average types. By adjusting the "Depth" setting, you can transform a standard moving average into its N-tuple counterpart. For example, if you select the EMA option with a depth of 2, the indicator produces a Double EMA (DEMA); a depth of 3 produces a Triple EMA (TEMA), and so forth up to a depth of 30.

The indicator supports multiple base moving average types, including EMA, SMA, WMA, RMA, and T3. These can be used in conjunction with "Loxx's Expanded Source Types," which allows the indicator to be calculated on various price points such as Heiken-Ashi variants or trend-biased sources. The bar coloring feature provides visual confirmation of the trend direction based on the slope or position of the N-tuple average.

Details

The script executes a nested calculation where each successive moving average is calculated based on the result of the previous one. To maintain the responsiveness of the moving average at higher depths, the script applies a binomial coefficient weighting system.

The implementation follows these steps:

  1. Factorial Calculation: The script calculates the factorial of the chosen depth.
  2. Weight Assignment: Weights for each nested layer are determined using the formula: factorial(depth) / (factorial(depth - k) * factorial(k)), where k represents the position in the stack.
  3. Coefficient Application: These coefficients are applied to each moving average layer to produce the final output. For instance, a 5-depth EMA (QEMA) is calculated by combining five nested EMAs with alternating signs and specific weights to offset the lag typically associated with multiple smoothing passes.

Settings

Source Settings

  • Smoothing Type: Selects the primary smoothing method (AMA, T3, or Kaufman).
  • Source: Choose from a wide variety of price sources, including standard prices, Heiken-Ashi, and Trend Biased options.

Basic Settings

  • Period: Sets the lookback period for the base moving average calculation.
  • Depth: Determines the number of nested moving averages (1 to 30).
  • Variety Moving Average Type: Selects the underlying MA algorithm (EMA, WMA, SMA, RMA, or T3).

T3 Settings

  • T3 Hot: Adjusts the volume factor for the T3 calculation.
  • T3 Type: Switches between "T3 New" and "T3 Original" calculation methods.

Moving Average Inputs

  • Fast End/Slow End: Specific parameters for Kaufman's Adaptive MA (KAMA).
  • Fast/Slow: Specific parameters for the Adaptive Moving Average (AMA).

UI Options

  • Color bars?: Enables or disables bar coloring based on the indicator's trend state.

FAQ

How do I use this to create a TEMA? Set the "Variety Moving Average Type" to EMA and the "Depth" to 3. This configuration mirrors the standard Triple Exponential Moving Average calculation.

Why is the depth limited to 30? While mathematically possible to go higher, the depth is capped at 30 to optimize processing speed and reduce indicator load times within the charting environment.

How can I access the Variety N-Tuple Moving Averages? 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.