Indicator · Pine Script v6 · Own pane

Jurik Directional Movement Index (DMX)

by mihakralj

DMX plots the Jurik Directional Movement Index in a separate pane.

View on GitHub

GitHub stars99on the repository
Pine versionv6current
Lines of code95
Settings1inputs
LicenceApache-2.0
Last update4 weeks ago27 Sep 2026

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

95 lines of Pine Script v6 from lib/dynamics/dmx/dmx.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

dmx.pine
// Licensed under the Apache License, Version 2.0
// © mihakralj
//@version=6
indicator("Jurik Directional Movement Index (DMX)", "DMX", overlay=false)

//@function Calculates DMX using Jurik's smoothing of ADX
//@param period Number of bars used in the calculation
//@returns dmx value
dmx(simple int period = 14) =>
    if period <= 0
        runtime.error("Period must be greater than 0")
    float tr = na(close[1]) ? high - low : math.max(high - low, math.max(math.abs(high - close[1]), math.abs(low - close[1])))
    float upDm = na(high[1]) ? 0.0 : high - high[1] > low[1] - low and high - high[1] > 0 ? high - high[1] : 0.0
    float downDm = na(low[1]) ? 0.0 : low[1] - low > high - high[1] and low[1] - low > 0 ? low[1] - low : 0.0
    float wilderAlpha = 1.0 / period
    var float upEma = na, var float upDi = na, var float upE = 1.0
    var bool upWarmup = true
    if not na(upDm)
        if na(upEma)
            upEma := 0
            upDi := upDm
        else
            upEma := wilderAlpha * (upDm - upEma) + upEma
            if upWarmup
                upE *= (1 - wilderAlpha)
                float upC = 1.0 / (1.0 - upE)
                upDi := upC * upEma
                if upE <= 1e-10
                    upWarmup := false
            else
                upDi := upEma
    var float downEma = na, var float downDi = na, var float downE = 1.0, var bool downWarmup = true
    if not na(downDm)
        if na(downEma)
            downEma := 0
            downDi := downDm
        else
            downEma := wilderAlpha * (downDm - downEma) + downEma
            if downWarmup
                downE *= (1 - wilderAlpha)
                float downC = 1.0 / (1.0 - downE)
                downDi := downC * downEma
                if downE <= 1e-10
                    downWarmup := false
            else
                downDi := downEma
    float sumDi = upDi + downDi
    float source = sumDi != 0.0 ? (upDi - downDi) / sumDi : 0.0
    var simple float PHASE_VALUE = 0.5
    var float power = 0.20
    var simple float BETA = power * (period - 1) / ((power * (period - 1)) + 2)
    var simple float LEN1 = math.max((math.log(math.sqrt(0.5*(period-1))) / math.log(2.0)) + 2.0, 0)
    var simple float POW1 = math.max(LEN1 - 2.0, 0.5)
    var simple float LEN2 = math.sqrt(0.5*(period-1))*LEN1
    var simple float POW1_RECIPROCAL = 1.0 / POW1
    var simple float AVG_VOLTY_ALPHA = 2.0 / (math.max(4.0 * period, 65) + 1.0)
    var simple float DIV = 1.0/(10.0 + 10.0*(math.min(math.max(period-10,0),100))/100.0)
    var float upperBand_state = na, var float lowerBand_state = na, var float ma1_state = na, var float jma_state = na
    var float vSum_state = 0.0, var float det0_state = 0.0, var float det1_state = 0.0, var float avgVolty_state = na
    var volty_array_state = array.new_float(11, 0.0)
    float dmx = na
    if not na(source)
        float del1 = source - nz(upperBand_state, source)
        float del2 = source - nz(lowerBand_state, source)
        float volty = math.abs(del1) == math.abs(del2) ? 0.0 : math.max(math.abs(del1), math.abs(del2))
        array.unshift(volty_array_state, nz(volty, 0.0))
        array.pop(volty_array_state)
        if not na(volty)
            vSum_state := vSum_state + (volty - array.get(volty_array_state, 10)) * DIV
            avgVolty_state := nz(avgVolty_state, vSum_state) + AVG_VOLTY_ALPHA * (vSum_state - nz(avgVolty_state, vSum_state))
        float rvolty = math.min(math.max(nz(avgVolty_state, 0) > 0 ? nz(volty, 0.0) / nz(avgVolty_state, 1.0) : 1.0, 1.0), math.pow(LEN1, POW1_RECIPROCAL))
        float pow2 = math.pow(rvolty, POW1)
        float Kv = math.pow(LEN2/(LEN2+1), math.sqrt(pow2))
        upperBand_state := del1 > 0 ? source : source - Kv * del1
        lowerBand_state := del2 < 0 ? source : source - Kv * del2
        float alpha = math.pow(BETA, pow2)
        float alphaSquared = alpha * alpha
        float oneMinusAlpha = 1.0 - alpha
        float oneMinusAlphaSquared = oneMinusAlpha * oneMinusAlpha
        ma1_state := source + (alpha * (nz(ma1_state, source) - source))
        det0_state := (source - ma1_state) * (1 - BETA) + BETA * nz(det0_state, 0)
        float ma2 = ma1_state + (PHASE_VALUE * det0_state)
        det1_state := ((ma2 - nz(jma_state, source)) * oneMinusAlphaSquared) + (alphaSquared * nz(det1_state, 0))
        jma_state := nz(jma_state, source) + det1_state
        dmx := jma_state
    dmx

// Inputs
i_period = input.int(14, "Period", minval=1, tooltip="Number of bars used in the calculation")

// Calculate ADX
dmx = dmx(i_period)

// Plot
plot(dmx, "DMX", color=color.yellow, linewidth=2)

Overview

The indicator computes a smoothed version of the directional movement index using Jurik smoothing applied to the ADX components derived from true range, up and down directional moves. It applies Wilder smoothing followed by Jurik moving average to the positive and negative directional indicators. The main setting adjusts the period length used in smoothing and calculations, defaulting to 14. This provides a trend and momentum measure by quantifying the strength and direction of directional movement. The script draws the DMX value on the chart in its own pane. No explicit buy or sell signals are provided and it functions as a standalone indicator without stop loss or pyramiding.

Details

Published by

mihakralj on GitHub

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Trend, Oscillators & momentum, Moving averages

Markets

Forex

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.

Topics

algorithmic-tradingcsharpdotnetpinescriptpythonquantitative-financesimdta-libtechnical-analysistechnical-indicators

Settings

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

SettingTypeDefaultVariable
Periodint14i_period
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

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
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

KamaFama

by Mastaaa1987
141 stars

KamaFama is an indicator that translates a Freqtrade trading strategy into Pine Script for visualization. It combines Kaufman Adaptive Moving Average (KAMA), MAMA/FAMA calculations derived via Hilbert Transform, Williams %R, and correlation trend filters to ev

Indicator v6 Moving averagesOscillators & momentum
Updated 6 weeks ago · MIT GitHub repository of KamaFama

MultiIndicator

by capissimo
114 stars

MultiIndicator combines multiple technical indicators into a single separate pane to save chart space. It calculates and displays market regime detection based on ordinary least squares regression, a Holt exponential smoothing crossover, normalized RSI, ADX, a

Indicator v4 Oscillators & momentumTrend
Updated 1 year ago · None stated GitHub repository of MultiIndicator
47 stars

This indicator calculates the Williams Gator Oscillator derived from Bill Williams Alligator lines and plots dual histograms in a separate pane. The upper histogram displays the absolute difference between the Jaw and Teeth moving averages, while the lower his

Indicator v6 Oscillators & momentumMoving averages
Updated 8 months ago · MIT GitHub repository of Williams Gator Oscillator
43 stars

This indicator plots the percentage difference between a fast exponential moving average and a slow one, scaled by the close, in a separate pane. It treats that gap as a standardized measure of trend strength and draws a zero line. Users set both EMA lengths a

Indicator v5 Moving averagesOscillators & momentum
Updated 1 year ago · None stated GitHub repository of Standardized MA Difference

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