All indicators

Mean Deviation Trail | Lyro RS

May 13, 2026

Static chart image
Price Action BasedDynamic OverlaysSupport and ResistanceSignalsDashboardMoving AveragesTrailing-StopVolatility

The Mean Deviation Trail indicator provides an adaptive trend-following overlay that utilizes Mean Absolute Deviation (MAD) to create a dynamic, self-adjusting trail based on price volatility and momentum. By normalizing price displacement from its mean, the tool offers a responsive tracking system that tightens during high-momentum regimes and widens during periods of consolidation.

Usage

The Mean Deviation Trail can be used to identify trend direction, potential entry/exit points, and trend strength. The trail acts as a dynamic support or resistance level, switching sides based on the smoothed deviation signal crossing zero.

  • Trend Identification: A "Long" label appears when the smoothed deviation crosses above zero, flipping the trail below the price. Conversely, a "Short" label appears when the deviation crosses below zero, flipping the trail above the price.
  • Volatility Adaptation: In strong trending environments where price deviates significantly from the mean, the trail tightens (hugs price) to protect gains. In choppy or low-momentum environments, the trail widens to avoid premature stop-outs.
  • Strength Assessment: Users can monitor the trend strength via the dashboard. "Strong" indicates a mature trend where the trail is tight, while "Weak" suggests a fading regime where the trail is loosening.
  • Visual Confirmation: The optional outer band can be used as a soft confirmation level or a target for partial profit-taking.

Details

The script functions through a multi-stage calculation engine:

  1. Deviation Engine: Calculations are anchored to an EMA of the price source. The signed normalized deviation is calculated as the difference between price and the EMA, divided by the MAD.
  2. MAD Normalization: Unlike Standard Deviation, Mean Absolute Deviation is used to normalize volatility. This method is less sensitive to extreme outlier spikes, resulting in a smoother volatility anchor.
  3. Adaptive Multiplier: The script scales the smoothed deviation signal against its 80-bar peak. This value determines the multiplier used for the trail width. If the deviation is high, the multiplier shifts toward the "Tight" setting; if low, it shifts toward the "Wide" setting.
  4. Signal Smoothing: The indicator includes 16 different moving average types to filter noise from the raw deviation signal, allowing users to customize the responsiveness of trend flips.

Settings

  • Source: The price data used for all calculations (default is Close).
  • MA Length: The lookback period for the EMA used as the central mean anchor.
  • Smoothing MA: Selects the moving average type (e.g., SMA, EMA, HMA, JMA) used to filter the deviation signal.
  • Smoothing Length: The period for the smoothing moving average.
  • MAD Length: The lookback period used for calculating the Mean Absolute Deviation volatility normalizer.
  • Multiplier Tight: The multiplier used when price deviation is strong, causing the trail to move closer to the price.
  • Multiplier Wide: The multiplier used when price deviation is weak, causing the trail to drift further from the price.
  • Color Mode: Choose between "Gradient" (intensity scales with trend strength) or "Trend" (solid colors).
  • Outer Band: Toggles the visibility of an additional band plotted at half-bandwidth on the opposite side of the mean.
  • Color Palette: Selects from several predefined color schemes (Classic, Mystic, Accented, Royal) or a custom user-defined palette.

FAQ

How do I interpret the trend strength labels? The strength label (Strong, Moderate, Weak) is determined by how close the current deviation is to its recent peak. A "Strong" reading suggests a mature, high-momentum trend, whereas a "Weak" reading suggests momentum is decaying or price is consolidating.

What is the advantage of using MAD over Standard Deviation? MAD (Mean Absolute Deviation) does not square the error terms like Standard Deviation does. This makes the volatility measurement less reactive to extreme outliers, providing a more stable and "smooth" anchor for the trail.

How can I access the Mean Deviation Trail? 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.