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


สแนปชอต

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


สแนปชอต

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.


สแนปชอต

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.


สแนปชอต

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

สคริปต์โอเพนซอร์ซ

ด้วยเจตนารมณ์หลักของ TradingView ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถเข้าใจและตรวจสอบได้ ต้องขอบคุณผู้เขียน! ที่ให้คุณใช้ได้ฟรี แต่การนำโค้ดนี้ไปใช้ในการเผยแพร่ซ้ำจะต้องอยู่ภายใต้ กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?

คำจำกัดสิทธิ์ความรับผิดชอบ