OPEN-SOURCE SCRIPT

Distance from MA (%)

Purpose:

This indicator calculates and plots the distance in percentage between the current price and a specified moving average. The distance is displayed in a separate window below the main price chart.
Features:

Configurable Moving Average Period: You can set the period for the moving average calculation.
Multiple Moving Average Methods: The indicator supports various moving average methods, including Simple Moving Average (SMA), Exponential Moving Average (EMA), Weighted Moving Average (WMA), and Volume Weighted Moving Average (VWMA).
Applied Price Selection: You can choose which price to use for the moving average calculation (e.g., close, open, high, low, etc.).

Parameters:

MA Period: The number of periods to use for the moving average calculation.
MA Method: The type of moving average to use (SMA, EMA, WMA, VWMA).
Applied Price: The price used for the moving average calculation.

Calculation:

Moving Average Calculation:
Depending on the selected method, the indicator calculates the moving average (MA) value for each bar using the specified period and applied price.
Distance in Percentage:
The distance is calculated as the difference between the current price and the moving average value, divided by the moving average value, and then multiplied by 100 to convert it to a percentage.
Formula: Distance %=(Applied Price−MA ValueMA Value)×100Distance %=(MA ValueApplied Price−MA Value​)×100

Plotting:

The indicator plots the calculated distance in percentage as a line in a separate window below the main chart. The plot is colored red and has a linewidth of 2 for better visibility.
Breadth Indicators

نص برمجي مفتوح المصدر

قام مؤلف هذا النص البرمجي بنشره وجعله مفتوح المصدر، بحيث يمكن للمتداولين فهمه والتحقق منه، وهو الأمر الذي يدخل ضمن قيم TradingView. تحياتنا للمؤلف! يمكنك استخدامه مجانًا، ولكن إعادة استخدام هذا الرمز في المنشور يخضع لقواعد‎‎قوانين الموقع. يمكنك جعله مفضلاً لاستخدامه على الرسم البياني.

هل تريد استخدام هذا النص البرمجي على الرسم البياني؟

إخلاء المسؤولية