Indicator · Pine Script v4 · Own pane

Directional Movement Index

by Zettt

This indicator calculates and plots the standard Directional Movement Index (DI+, DI-, and ADX) in an oscillator pane alongside colored horizontal zones representing trend strength stages: weak, medium, strong, and exhaustion.

View on GitHub

GitHub stars43on the repository
Pine versionv4older, still runs
Lines of code54
Settings6inputs
LicenceNone statedfile: MPL-2.0
Last update1 year ago23 Sep 2025

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

54 lines of Pine Script v4 from DMI.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

DMI.pine
// ================================================================================================================================================================================
// DMI indicator with colored zones
// ================================================================================================================================================================================
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Original by TradingView
// Rewritten by Zettt
// This version only differs from the original TradingView version in the way that it displays zones in different colors. Scripts like this won't get published in the TV App Store.

//@version=4
study(title="Directional Movement Index", shorttitle="DMI", format=format.price, precision=4)

//
// Configuring DMI
lensig = input(title="ADX Smoothing", defval=6, minval=1, maxval=50)
longmultiplier = input(title="ADX Multiplier", defval=4, minval=1, maxval=24)
len = input(title="DI Length", defval=14, minval=1)
[diplus, diminus, adx] = dmi(len, lensig)
// Additional DMI indicator which uses multiple values of the original DMI
[dipluslong, diminuslong, adxlong] = dmi(len * longmultiplier, lensig * longmultiplier)

//
// Configuring and plotting zones
ADX_wm_threshold = input(defval=25,title="ADX Weak Threshold", minval=0)
ADX_ms_threshold_f = input(defval=50,title="ADX Weak Threshold", minval=0)
osob_f = input(defval=75,title="ADX Weak Threshold", minval=0)
h0 = hline(0, linestyle=hline.style_dotted, color=color.black, linewidth = 1, title="ADX 0 Line")
h_wm = hline(ADX_wm_threshold, linestyle=hline.style_dotted, color=color.black, linewidth = 1, title="ADX Weak Threshold")
h_ms = hline(ADX_ms_threshold_f, linestyle=hline.style_dotted, color=color.black, linewidth = 1, title="ADX Medium Threshold")
h_osob = hline(osob_f, linestyle=hline.style_dotted, color=color.black, linewidth = 1, title="ADX Exhaustion threshold") 
h100 = hline(100, linestyle=hline.style_dotted, color=color.white, linewidth = 1, title="ADX 100 Line") 

fill(h0, h_wm, title="ADX = weak", color=#c9daf8, transp=96)
fill(h_wm, h_ms, title="ADX = medium", color=#a2c0f7, transp=96)
fill(h_ms, h_osob, title="ADX = strong", color=#7ba4ed, transp=96)
fill(h_osob, h100, title="ADX = 75 to 100", color=#5888bb, transp=96)

//
// Plotting the standard DMI
adxStronger = adx[1] <= adx
plot(adx, color=adxStronger ? #64b5f6 : #bbdefb, title="ADX", style=plot.style_line, linewidth=1)
plot(diplus, color=diplus >= diminus ? #81c784 : #c8e6c9, title="DI+")
plot(diminus, color=diminus >= diplus ? #e57373 : #ffcdd2, title="DI+")
// diEMA = input(title="DI EMA", defval=9, minval=1)
// adxSMA = input(title="ADX SMA", defval=2, minval=1)
// plot(sma(adx, adxSMA), color=color.orange, title="ADX SMA", display=display.none)
// plot(ema(diplus, diEMA), color=color.orange, title="DI+ EMA", display=display.none)
// plot(ema(diminus, diEMA), color=color.orange, title="DI- EMA", display=display.none)

//
// Plotting the long DMI
// ADX is colored differently depending on whether it is above or below threshold
plot(adxlong, color=adxlong >= ADX_wm_threshold ? #fbc02d : #fff9c4, title="ADX Long", style=plot.style_line, linewidth=1, display=display.none)
plot(dipluslong, color=#81c784, title="DI+ Long", display=display.none)
plot(diminuslong, color=#e57373, title="DI+ Long", display=display.none)

Overview

The ADX line dynamically shades based on whether it is rising or falling, while DI lines adjust shade depending on directional dominance. It also calculates a longer-period DMI overlay that is hidden by default. Main settings configure the smoothing periods, length multiplier, and threshold levels.

Details

Published by

Zettt on GitHub

Type

Indicator, Pine Script v4

Draws

Separate pane below the chart

Category

Trend, Oscillators & momentum

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
ADX Smoothingint6lensig
ADX Multiplierint4longmultiplier
DI Lengthint14len
ADX Weak Thresholdint25ADX_wm_threshold
ADX Weak Thresholdint50ADX_ms_threshold_f
ADX Weak Thresholdint75osob_f
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Schaff Trend Cycle

by everget
948 stars

This indicator plots the Schaff Trend Cycle in a separate pane. It subtracts a slow exponential moving average from a fast one, applies a stochastic cycle twice, and smooths each result to form a 0–100 oscillator. Line color follows the slope, or the upper and

Indicator v4 Oscillators & momentumTrend
Updated 10 days ago · GPL-3.0 GitHub repository of Schaff Trend Cycle

Beep Boop

by magic8bot
409 stars

This indicator calculates a modified MACD oscillator and signal line alongside a trend EMA filter, plotting the output as a stylized column histogram in a separate pane. Instead of plotting true MACD distance, it quantifies positive and negative histogram mome

Indicator v4 Oscillators & momentumTrend
Updated 3 years ago · MIT GitHub repository of Beep Boop

[RS]Standardized Trend Map

by ricardosantos79
261 stars

Standardized Trend Map calculates series momentum relative to active price range across 40 distinct lookback periods ranging from 2 to 80 bars on an exponential moving average source. Each standardized calculation rounds to an integer values of -1, 0, or 1 to

Indicator v4 TrendOscillators & momentum
Updated 4 years ago · None stated GitHub repository of [RS]Standardized Trend Map

ADX Histogram

by harryguiacorn
219 stars

This indicator calculates and displays the Average Directional Index (ADX) as a column histogram in a separate pane. It evaluates market trend strength by calculating directional movement metrics based on specified smoothing and DI length inputs. When the ADX

Indicator v5 TrendOscillators & momentum
Updated 1 year ago · None stated GitHub repository of ADX Histogram
218 stars

Multi-Timeframe Analysis Suite calculates trend direction and momentum conditions across five user-selected timeframes using moving averages, RSI, and Stochastic oscillators. It evaluates moving average slope and oscillator levels to compute trend alignment, m

Indicator v6 Screeners & dashboardsTrend
Updated 3 months ago · None stated GitHub repository of Multi-Timeframe Analysis Suite

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers