OPEN-SOURCE SCRIPT

Moving Average Ratio [InvestorUnknown]

Overview

The "Moving Average Ratio" (MAR) indicator is a versatile tool designed for valuation, mean-reversion, and long-term trend analysis. This indicator provides multiple display modes to cater to different analytical needs, allowing traders and investors to gain deeper insights into the market dynamics.

Features

1. Moving Average Ratio (MAR):
  • Calculates the ratio of the chosen source (close, open, ohlc4, hl2 …) to a longer-term moving average of choice (SMA, EMA, HMA, WMA, DEMA)
  • Useful for identifying overbought or oversold conditions, aiding in mean-reversion strategies and valuation of assets.
  • For some high beta asset classes, like cryptocurrencies, you might want to use logarithmic scale for the raw MAR, below you can see the visual difference of using Linear and Logarithmic scale on BTC


ảnh chụp nhanh

2. MAR Z-Score:
  • Computes the Z-Score of the MAR to standardize the ratio over chosen time period, making it easier to identify extreme values relative to the historical mean.
  • Helps in detecting significant deviations from the mean, which can indicate potential reversal points and buying/selling opportunities


ảnh chụp nhanh

3. MAR Trend Analysis:
  • Uses a combination of short-term (default 1, raw MAR) and long-term moving averages of the MAR to identify trend changes.
  • Provides a visual representation of bullish and bearish trends based on moving average crossings.
  • Using Logarithmic scale can improve the visuals for some asset classes.


ảnh chụp nhanh

4. MAR Momentum:
  • Measures the momentum of the MAR by calculating the difference over a specified period.
  • Useful for detecting changes in the market momentum and potential trend reversals.


5. MAR Rate of Change (ROC):
  • Calculates the rate of change of the MAR to assess the speed and direction of price movements.
  • Helps in identifying accelerating or decelerating trends.


ảnh chụp nhanh

MAR Momentum and Rate of Change are very similar, the only difference is that the Momentum is expressed in units of the MAR change and ROC is expressed as % change of MAR over chosen time period.


Customizable Settings

General Settings:
  • Display Mode: Select the display mode from MAR, MAR Z-Score, MAR Trend, MAR Momentum, or MAR ROC.
  • Color Bars: Option to color the bars based on the current display mode.
  • Wait for Bar Close: Toggle to wait for the bar to close before updating the MAR value.


MAR Settings:
  • Length: Period for the moving average calculation.
  • Source: Data source for the moving average calculation.
  • Moving Average Type: Select the type of moving average (SMA, EMA, WMA, HMA, DEMA).


Z-Score Settings:
  • Z-Score Length: Period for the Z-Score calculation.


Trend Analysis Settings:
  • Moving Average Type: Select the type of moving average for trend analysis (SMA, EMA).
  • Longer Moving Average: Period for the longer moving average.
  • Shorter Moving Average: Period for the shorter moving average.


Momentum Settings:
  • Momentum Length: Period for the momentum calculation.


Rate of Change Settings:
  • ROC Length: Period for the rate of change calculation.



Calculation and Plotting

Moving Average Ratio (MAR):
  • Calculates the ratio of the price to the selected moving average type and length.
  • Plots the MAR with a gradient color based on its Z-Score, aiding in visual identification of extreme values.




MAR Z-Score:
  • Computes the Z-Score of the MAR and plots it with a color gradient indicating the magnitude of deviation from the mean.




MAR Trend:
  • Plots the MAR along with its short-term and long-term moving averages.
  • Uses color changes to indicate bullish or bearish trends based on moving average crossings.




MAR Momentum:
  • Plots the momentum of the MAR, coloring the bars to indicate increasing or decreasing momentum.




MAR Rate of Change (ROC):
  • Plots the ROC of the MAR, using color changes to show the direction and strength of the rate of change.





Summary:
This multi-purpose indicator provides a comprehensive toolset for various trading strategies, including valuation, mean-reversion, and trend analysis. By offering multiple display modes and customizable settings, it allows users to tailor the indicator to their specific analytical needs and market conditions.



CycleseducationalTrend Analysis

Mã nguồn mở

Theo tinh thần TradingView thực sự, tác giả của tập lệnh này đã xuất bản dưới dạng nguồn mở để các nhà giao dịch có thể hiểu và xác minh. Chúc mừng tác giả! Bạn có thể sử dụng miễn phí. Tuy nhiên, bạn cần sử dụng lại mã này theo Quy tắc nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?

Thông báo miễn trừ trách nhiệm