All indicators

Moving Average Ratio

Jul 31, 2024

Static chart image
SignalsOscillatorsMoving Averages

The Moving Average Ratio indicator provides a versatile toolkit for asset valuation, mean-reversion, and long-term trend analysis by calculating the ratio between price and a selected moving average. This tool allows traders to identify overextended market conditions and potential trend reversals through multiple analytical lenses including Z-Scores, Momentum, and Rate of Change.

Usage

The Usage section describes how the script can be used to identify market extremes and trend shifts. The indicator offers five distinct display modes:

  • MAR (Moving Average Ratio): Displays the raw ratio of the price to a long-term moving average. This is useful for identifying when an asset is historically overvalued (high ratio) or undervalued (low ratio).
  • MAR Z-Score: Standardizes the ratio over a historical period. This mode highlights statistical outliers, where values exceeding ±2 or ±3 typically indicate extreme overbought or oversold conditions.
  • MAR Trend: Utilizes a crossover system of two moving averages applied to the MAR itself. It is used to confirm bullish or bearish trend shifts based on the relative position of a short-term and long-term MAR average.
  • MAR Momentum: Measures the absolute change in the MAR over a specific period. It helps in detecting early signs of trend exhaustion or acceleration.
  • MAR Rate of Change (ROC): Similar to momentum but expressed as a percentage. This allows for a normalized view of how fast the ratio is changing relative to its previous values.

Details

The script functions by first calculating a "Main" moving average (defaulting to a 365-period SMA). The Moving Average Ratio (MAR) is then derived by dividing the price source by this average.

For the Z-Score calculation, the script applies a logarithmic transformation to the MAR values. This is particularly effective for high-beta assets like cryptocurrencies, as it normalizes exponential price growth. The Z-Score is then calculated by subtracting the SMA of the log-MAR from the current log-MAR and dividing by the standard deviation.

The Trend Analysis mode employs a double moving average crossover logic on the MAR value, while Momentum and ROC provide secondary derivatives to assess the "velocity" of the price's deviation from its mean.

Settings

General Settings

  • Display Mode: Switches the visual output between MAR, MAR Z-Score, MAR Trend, MAR Momentum, and MAR ROC.
  • Color bars?: When enabled, colors the price bars on the chart to match the selected indicator mode's logic.
  • Wait for Bar Close?: If enabled, the calculation uses the previous bar's data to prevent repainting.

MAR Settings

  • Length: The lookback period for the primary moving average.
  • Source: The price input used for the calculation (e.g., Close, OHLC4).
  • Moving Average Type: Selects the smoothing method (SMA, EMA, WMA, HMA, or DEMA).

Z-Score Calculation

  • Z-Score Length: The period used to calculate the mean and standard deviation for standardization.

Trend Analysis

  • Moving Average Type: The smoothing method for the trend crossover (SMA or EMA).
  • Longer Moving Average: The period for the slow trend line.
  • Shorter Moving Average: The period for the fast trend line.

Momentum & Rate of Change

  • Momentum Length: The lookback period for calculating absolute change.
  • ROC Length: The lookback period for calculating percentage change.

FAQ

How do I interpret the MAR Z-Score? The Z-Score indicates how many standard deviations the current price ratio is from its mean. Values above 2 or 3 are often considered overbought, while values below -2 or -3 are considered oversold.

What is the benefit of using the Logarithmic scale in this script? The script uses log-transformed MAR for Z-Scores to better handle assets with high volatility and exponential growth, ensuring that historical extremes remain relevant to current price action.

How can I access the Moving Average Ratio 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.