All indicators

Adaptive Trend Classification: Moving Averages

Jun 19, 2024

Static chart image
SignalsMoving Averages

The Adaptive Trend Classification: Moving Averages indicator is an adaptable investment tool that provides dynamic trend signals by weighting multiple moving average types based on their historical equity performance. This system utilizes advanced adaptability layers, including performance-based weighting and exponential decay, to ensure that the most effective trend-following methods influence the final signal in real-time.

Usage

The Usage section describes how the script can be used to identify trends and filter market noise. Users can interpret the indicator through several layers of output:

  • Trend Identification: The indicator generates a unified "Average" signal derived from six different moving average types (EMA, HMA, WMA, DEMA, LSMA, and KAMA). When the average signal crosses above the Long Threshold or below the Short Threshold, it indicates a potential trend shift.
  • Performance-Based Weighting: The script calculates "equity" for each moving average type. A moving average that has historically captured trends more accurately will receive a higher weight, making the indicator's output adaptive to specific assets and timeframes.
  • Calibration: By enabling Calibration Mode, users can isolate a specific moving average type to fine-tune its length and performance before integrating it into the weighted average.
  • Visualization: Users can toggle individual moving average plots and choose which calculation source (the weighted average or a specific MA type) should drive the bar coloring and signal arrows.

Details

The script operates on two primary layers of adaptability:

  1. Robustness Lengths: For every chosen moving average type, the script calculates a "set" of nine moving averages with slightly different lengths (based on the Narrow, Medium, or Wide setting). This reduces the sensitivity to a single length (the "length bias").
  2. Dynamic Equity Weighting: The indicator simulates performance for every moving average set. It calculates the rate of return and applies an Exponential Growth Factor (λ) and a Decay Rate.
    • λ (Lambda): Ensures that more recent performance has a significantly higher impact on the weight than older data.
    • Decay: Gradually depreciates the accumulated equity, preventing historical performance from indefinitely dominating the calculation if the market regime changes.

The final output is a weighted average of all active signals, providing a "consensus" view of the trend based on which models are currently performing best.

Settings

Adaptability Settings

  • λ (Lambda): Specifies the growth rate for exponential growth calculations. Higher values make the weightings more sensitive to recent performance.
  • Decay (%): Determines the rate of depreciation applied to the accumulated equity over time.
  • CutOut Period: Sets the number of initial bars to exclude from equity calculations to focus on a specific time range.
  • Robustness Lengths: Options (Narrow, Medium, Wide) that define the spread of the nine moving averages calculated for each type.
  • Long/Short Threshold: The numerical levels the average signal must cross to trigger a trend change.
  • Calculation Source: The price data (e.g., Close, HL2) used for all moving average calculations.

Moving Averages Settings

  • Length: Sets the base period for each moving average type (EMA, HULL, WMA, DEMA, LSMA, KAMA).
  • Weight: Sets the initial weight for each type before the dynamic equity adjustment is applied.

Calibration Mode

  • Calibration Mode: When enabled, the indicator focuses on a single moving average type for optimization.
  • Calibrate: Selects which specific MA type to display during calibration.
  • Strategy View: Shifts entries/exits by one bar to simulate non-repainting backtesting results.

FAQ

How does the indicator decide which moving average is "best"? It calculates a simulated equity curve for each moving average. The averages that have generated higher returns in the recent past (adjusted by the Lambda and Decay settings) are assigned higher weights in the final trend calculation.

Does this indicator repaint? The indicator supports intra-bar changes while a candle is open, but signals are fixed once the bar closes. Enabling "Strategy View" ensures signals are only processed after the bar close for backtesting accuracy.

How can I access the Adaptive Trend Classification: Moving Averages 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.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

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