OPEN-SOURCE SCRIPT

DMI ForLoop [InvestorUnknown]

已更新
Overview
This indicator utilizes the Directional Movement Index (DMI) combined with a for-loop to provide a robust trend analysis (ADX is not a part of this indicator).

Settings

DMI ForLoop Settings:
Start Length (a): The initial length for DMI calculation (inclusive).
End Length (b):The final length for DMI calculation (inclusive).
EMA Length (c): The length for the Exponential Moving Average applied to the DMI values, in order so smoothen the signal.

Signal Settings:
Signal Mode: Determines the mode of signal calculation. Options are "Fast", "Slow", "Thresholds Crossing", and "Fast Threshold". Default is "Fast".
1. Slow: is a simple crossing of the midline (0).
2. Fast: positive signal depends if the current "DMIema" is above "DMIema[1]" or above 0.99, otherwise the signal is negative.
3. Thresholds Crossing: simple ta.crossover and ta.crossunder of the user defined threshold for Long and Short.
4. Fast Threshold: signal changes if the value of "DMIema" changes by more than user defined threshold against the current signal.




Functionality
The DMI ForLoop indicator calculates an array of DMI values over a specified range of lengths, then averages these values and applies an EMA for smoothing. The result is a dynamic trend indicator that adapts to market conditions.

DMI Calculation:
The indicator iterates through lengths from Start Length to End Length, calculating the positive and negative directional movement (DM) for each period and calculates the average of all the signals at the end. A custom function version of the DMI is used here in order to use DMI with "series" inputs.



This indicator is versatile and can be tailored to fit various trading/investing strategies by adjusting the input parameters and signal modes.
版本注释
Update:

- option to choose different type of Moving Average



- Adjusted signal calculation for the "Fast" signal to work well with different types of the Moving Average



- Added Alerts


Trend Analysis

开源脚本

本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受网站规则约束。 您可以收藏它以在图表上使用。

想在图表上使用此脚本?

免责声明