IronCasper

Directional Movement Index (DMI) + Alerts

This is a Study with associated visual indicators and Bullish / Bearish Alerts for Directional Movement (DMI). It consists of an Average Directional Index ( ADX ), Plus Directional Indicator ( +DI ) and Minus Directional Indicator ( -DI ).

Published by J. Welles Wilder in 1978 for use with currencies and commodities which are typically more volatile than stocks and have stronger trends.

Development Notes
---------------------------
This indicator, and most of the descriptions below, were derived largely from the TradingView reference manual. Feedback and suggestions for improvement are more than welcome, as well are recommended Input settings and best practices for use.

https://www.tradingview.com/chart/?solut...

Strategy Description
---------------------------
ADX defines whether or not there is a trend present; +DI and -DI compliment the ADX by taking direction into account. An ADX above 25 indicates a strong trend, and a Bullish alert is subsequently triggered when +DI is above -DI and a Bearish alert when -DI is above +DI .

Note that the Bullish or Bearish crossover alert will only trigger if ADX is simultaneously above 25 during the crossover event. If ADX later rises to 25 and +DI is still greater than -DI , or -DI greater than +DI , then a delayed alert will not trigger by design.

Basic Use
---------------------------
Acceptable DMI values are up to the trader's interpretation and may change depending on the financial instrument being examined. Recommend not changing any default values without being first familiar with their purpose and impact on the indicator at large.

Confidence in price action and trend is higher when two or more indicators are in agreement -- therefore we recommend not using this indicator by itself to determine entry or exit trade opportunities.

Recommend also choosing 'Once Per Bar Close' when creating alerts.

Inputs
---------------------------
ADX Smoothing - the time period to be used in calculating the ADX which has a smoothing component (14 is the Default).

DI Length - the time period to be used in calculating the DI (14 is the Default).

Key Level - any trade with the ADX above the key level is a strong indicator that it is trending (23 to 25 is the suggested setting).

Sensitivity - an incremental variable to test whether the past n candles are in the same bullish or bearish state before triggering a delayed crossover alert (3 is the Default). Filter out some noise and reduces active alerts.

Show ADX Option - two visual styles are provided for user preference, a visible ADX line or a background overlay (green or red when ADX is above the key level, for bullish or bearish , and gray when below).

Color Candles - an option to transpose the bullish and bearish crossovers to the main candle bars. Can be turned off in the Style Tab by deselecting 'Bar Colors'. Dark blue is bullish , dark purple is bearish , and the black inner color is neutral. Note that the outer red and green border will still be distinguished by whether each individual candle is bearish or bullish during the specified timeframe.

Indicator Visuals
---------------------------
Bullish or Bearish plot based on DMI strategy ( ADX and +/ -DI values).

Visual cues are intended to improve analysis and decrease interpretation time during trading, as well as to aid in understanding the purpose of this study and how its inclusion can benefit a comprehensive trading strategy.

Trend Strength
---------------------------
To analyze trend strength, the focus should be on the ADX line and not the +DI or -DI lines.  An ADX reading above 25 indicates a strong trend, while a reading below 20 indicates a weak or non-existent trend.  A reading between those two values would be considered indeterminable. Though what is truly a strong trend or a weak trend depends on the financial instrument being examined; historical analysis can assist in determining appropriate values.

Bullish DI Cross
---------------------------
1. ADX must be over 25 (strong trend) (value is determined by the trader)
2. +DI cross above -DI
3. Set Stop Loss at the current day's low (any +DI cross-backs below -DI should be ignored)
4. Set trailing stop if ADX strengthens (i.e., signal rises)

Bearish DI Cross
---------------------------
1. ADX must be over 25 (strong trend) (value is determined by the trader)
2. -DI cross above +DI
3. Set Stop Loss at the current day's high (any -DI cross-backs below +DI should be ignored)
4. Set trailing stop if ADX strengthens (i.e., signal rises)

Disclaimer
---------------------------
This post and the script are not intended to provide any financial advice. Trade at your own risk.

No known repainting.
Release Notes: Revision Note: Updated indicator to hide key level line if background view is selected.
Release Notes: Note: the last update messed up the chart visual -- revising to fix.
Release Notes: ...
Release Notes: Attempting to update chart again. Three views shown: ADX as a background color, ADX as a line with Key Level line, and a compact background color and label only view.
Release Notes: Version 1.1
-------------------------
- Added multi-timeframe resolution using PineCoders secure security function to eliminate repainting.

- Cleaned up option for selecting ADX view; and added a colored line as a choice, based on same bullish, bearish, or neutral colors as the background.

- Added exit crossover indicator to aid in an overall strategy development. This ability pairs better with my CHOP Zone Entry Strategy which relies on DMI Exits. Note that exit conditions don't employ the sensitivity variable. Green labels are for Bullish exits and red are for Bearish.

-- Exit condition is triggered if in an active Bullish or Bearish position and ADX drops below 25, Or if either the -DI crosses above +DI (for previously Bullish) or +DI crosses above -DI (for previously Bearish).

- Added reverse position determination. Triggers when a Bullish entry occurs on the same candle as a Bearish exit, or vice versa. Green labels are for Bullish reverses and red are for Bearish.

- Added selectable option to choose visible labels -- Bearish, Bullish, Both, Exits, Reverses, or All.

-- Note that a reverse label will only show if the opposing entry and exit labels are set to show, otherwise the reverse will revert to the appropriate entry or exit on the chart.

- Added alerts to account for new conditions.

-- Note that alerts for crossovers, exits, and reverses will only be triggered if the associated labels are selected to be shown (i.e., what you choose to see on the chart is what you will be alerted to).
Release Notes: If multi-timeframe resolution is selected, the true range was updated to be based on the same higher time frame as high/low in the DMI calculation.
Release Notes: Version 1.2
-------------------------
- Changed exit condition to be decided on by whether ADX is below 25 and on a +/-DI crossover. Versus being either or. The previous version had too many false triggers. This variety can now show multiple Bullish or Bearish alerts before an Exit condition too. I'm tempted to simply make this condition based on ADX, and not DI … thoughts? See lines 138 and 139.

- Updated the Background view to have deeper shades of colors dependent upon the ADX trend strength.

- Added an Oscillator view for the ADX and momentum computations to color the histogram by trend. DI lines are hidden.

-- If ADX is Bullish, then the oscillator is colored light green in an uptrend and dark green in a downtrend; if Bearish, then its light red in an uptrend and dark redin a downtrend; if adx is below key level, then it is light gray in a downtrend and dark grey in the uptrend.

- Added option to Hide ADX in case only the Directional lines are desired. This could be useful if you would like to have the ADX oscillator in one panel and +/-DI crossovers in another.

- Added a Columnar view for the ADX. DI lines are hidden. This view is really simple and compact, with the trend strength still easily understood. Colors are the same as for the oscillator -- the deeper the shade of green or red, then the higher the ADX trend strength level.

- Added a Trend Strength label.

ADX Trend Strength Trade (Y/N) Setup Types
0 to 10 = Barely Breathing N N/A
10 to 20 = Weak Trend Y Range/Pre-Breakout
20 to 30 = Potentially Starting to Trend Y Early Stage Trend
30 to 50 = Strong Trend Y Ride the Wave
50 to 75 = Very Strong Trend N Exhaustion
75 to 100 = Extremely Strong Trend N N/A

Release Notes: Version 1.21

Minor edits.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Comments

Broken
Reply
I CANT ADD THE SCRIPT, BROKEN?
Reply
Just a heads up...
The alert conditios from line 319 and beyond don't compile with // Revision: 1.21
Reply
Home Stock Screener Forex Screener Crypto Screener Economic Calendar How It Works Chart Features Pricing Refer a friend House Rules Help Center Website & Broker Solutions Widgets Charting Solutions Lightweight Charting Library Blog & News Twitter
Profile Profile Settings Account and Billing Referred friends Coins My Support Tickets Help Center