DMI Stochastic Momentum Index

andre_007 Actualizado   

This is an improved version of the "DMI Stochastic Extreme Refurbished" indicator.

For more information on the main concepts of this indicator, please access this link:

The difference is that here, instead of using the traditional stochastic oscillator, I implemented the use of the Stochastic Momentum Index (SMI).

Stochastic Momentum Index (SMI)

The SMI is considered a refinement of the stochastic oscillator.
It calculates the distance of the current closing price as it relates to the median of the high/low range of price.
William Blau developed the SMI, which attempts to provide a more reliable indicator, less subject to false swings.

The original stochastic is limited to values from 0 to 100, while the SMI varies between the range of -100 to 100.

It is worth mentioning that the SMI presented in this script applies to the DMI value, not the screen price.
Notas de prensa:
- Now SMI can be based on DMI or price (conventional way).
- Regrouping of fields.
- Fine tuning in the alerts parameterization.
- Improved parameterization of colors.
- New level lines added.
Notas de prensa:
1. Modified default parameters.
2. Improved colors.
3. Changed bar graph to histogram.
4. Improved text.
5. Corrected color bar logic.
Notas de prensa:
Fixed histogram color when below zero.
Notas de prensa:
1. Updated code to use a library and save code.
2. Added Dynamic Zones.
3. Now the TSI is calculated only based on the DMI that is displayed on the screen via histogram, or via price (original SMI). Previously it could be displayed based on a second DMI parameter (which was not displayed in the histogram). This extra DMI parameter was removed in order to simplify the indicator.
4. Added themes.
5. Removed excess averages options.
6. Added bar\candlesticks coloring options.
7. Added intersection alerts.

▮ Complementing the description

The Directional Movement Index (DMI) is a technical indicator used in technical analysis to help determine whether an asset is in an uptrend, a downtrend, or a period of consolidation. It was developed by J. Welles Wilder Jr. and published in his book "New Concepts in Technical Trading Systems".

The DMI is made up of three lines: the ADX (Average Directional Movement Index) line, which indicates the strength of the current trend; the +DI (Positive Directional Indicator) line, which shows the strength of the uptrend; and the -DI (Negative Directional Indicator) line, which shows the strength of the downtrend.

When the ADX line is above 25, it indicates that there is a strong trend going on. When the +DI line crosses above the -DI line, it is a signal that the trend is changing into an uptrend. When the -DI line crosses above the +DI line, it is a signal that the trend is changing into a downtrend.

The DMI is a useful tool for traders and investors who want to spot trends and make informed decisions based on technical data. It is important to remember, however, that no technical indicator is foolproof and that technical analysis should be used in conjunction with other forms of analysis such as fundamental analysis and market sentiment analysis.

It is worth pointing out that the DMI used here, as proposed by the author of the 'DMI Stochastic Extreme' indicator (Barbara Star), refers to the absolute value between DI+ and DI-, that is, (DI+) - (DI-) = x.

▮ About Dynamic Zones

'Most indicators use a fixed zone for buy and sell signals.
Here's a concept based on zones that are responsive to the past levels of the indicator.'

The concept of Dynamic Zones was described by Leo Zamansky ( Ph .D.) and David Stendahl, in the magazine of Stocks & Commodities V15:7 (306-310).
Basically, a statistical calculation is made to define the extreme levels, delimiting a possible overbought/oversold region.

Given user-defined probabilities, the percentile is calculated using the method of Nearest Rank.
It is calculated by taking the difference between the data point and the number of data points below it, then dividing by the total number of data points in the set.
The result is expressed as a percentage.

This provides a measure of how a particular value compares to other values in a data set, identifying outliers or values that are significantly higher or lower than the rest of the data.

▮ Examples

- SMI DMI versus original SMI:

What the examples suggest is that the SMI is more effective at identifying overbought and oversold regions.
While SMI DMI, due to the nature of DMI, is more useful in identifying trends and divergences, presenting less noise in the histogram.
Notas de prensa:
Adjustment of default parameters.
Notas de prensa:
- Added new themes:


- Added limits customization for gradient theme (last theme in the list, which is now 26):
Notas de prensa:
Minor fixes:
- The term "Opacity" was not correct. The correct one is "Transparency".
Notas de prensa:
- Added a parameter to customize the Histogram transparency level.
This can be useful to make the graph less cluttered in certain situations.
Below is an example with the type changed from Histogram to Area (in the Style tab), and then with the transparency level at 70%:

- New themes added.
The themes were reorganized by value ranges, in order to facilitate the choice and future implementations:

10 to 15 → Spectrum Blue-Green-Red
20 to 21 → Monokai
30 to 31 → Spectrum White-Green-Red
40 to 41 → Green-Purple
50 to 51 → Blue-Red
60 to 61 → Blue-Yellow
70 to 71 → Green-Red
80 to 81 → Green
90 to 91 → Purple
100 to 107 → Blue
120 to 123 → Blue-Aqua
130 to 133 → Blue-Green
140 to 153 → Red
160 to 161 → Red-Yellow
170 to 171 → Red-White
180 to 185 → White-Black
190 to 191 → Spectrum Blue-Red

Codes 190, 191:

- Fine adjustments were made in the standard parameters of Levels for TSI's Theme and Signal's Theme aiming at a better visualization of the colors.

- Added 2 color gradient format theme option for Histogram.

- Improved crossing alert messages. There are now 8 alerts available:

1. 'TSI crossing above Signal when within limits'
2. 'TSI crossing below the Signal when within limits'
3. 'TSI exiting the Dynamic Zone at the top'
4. 'TSI entering the Dynamic Zone at the top'
5. 'TSI exiting the Dynamic Zone at the bottom'
6. 'TSI entering the Dynamic Zone at the bottom'
7. 'TSI crossing above the centerline'
8. 'TSI crossing below the centerline'

There are now two ways to add alerts over here:

In the first form, technically speaking, the alert() function is used. This is the fastest way and works best with automations.
Alerts are chosen via indicator parameters. That done, then just add the "Any alert()" alert, as indicated in circle 1.

The second way is more laborious, but allows individual insertion of alerts.
Note that in this case, the checkboxes mentioned above make no difference.

Due to the added alerts using the alert() function, I had to remove the timeframe parameterization.
Notas de prensa:
Minor fixes
Notas de prensa:
New parameter to select a different timeframe.

Notas de prensa:
- Correction in theme "1" (User defined). The colors weren't showing up correctly.


After correction:

- Removed unnecessary "var" declarations in order to follow official best practices.

- Added new themes:
Notas de prensa:

1. Added a repaint option (thanks for @Pinecoders).
2. Added a new option for Histogram: "Multiplier".
Using longer periods, the histogram can become flattened, making it difficult to see. The multiplier solves that.
3. DI Length for DMI Histogram: default value changed to 55.
4. Minor fixes in tooltips.
5. Source for price changed from hl2 to ohlc4.
6. TSI Long Length changed from 21 to 8.
7. TSI Short Length changed from 8 to 5.
8. Minor change in default colors.
9. Added separate alerts for TSI crosses inside/outside Dynamic Zone, with separate bounds for both.
Crossing points were repositioned to facilitate visualization.
10. Added trend lines with breakouts (thanks to @HoanGhetti -
11. Added divergence detector (thanks to TradingView -
12. Default values for histogram changed to match new values.
13. Removed alertcondition function to permit show divergence detector (due to limitation of maximum number of elements in screen).
Notas de prensa:
Minor fix in text

Script de código abierto

Siguiendo el verdadero espíritu de TradingView, el autor de este script lo ha publicado en código abierto, para que los traders puedan entenderlo y verificarlo. ¡Un hurra por el autor! Puede utilizarlo de forma gratuita, aunque si vuelve a utilizar este código en una publicación, debe cumplir con lo establecido en las Normas internas. Puede añadir este script a sus favoritos y usarlo en un gráfico.

Exención de responsabilidad

La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.

¿Quiere utilizar este script en un gráfico?