Indicator · Pine Script v6 · Own pane

Average Directional Movement Index Rating (ADXR)

by mihakralj

This indicator plots Average Directional Movement Index Rating in a separate pane.

View on GitHub

GitHub stars99on the repository
Pine versionv6current
Lines of code54
Settings2inputs
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

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

adxr.pine
// Licensed under the Apache License, Version 2.0
// © mihakralj
//@version=6
indicator("Average Directional Movement Index Rating (ADXR)", "ADXR", overlay=false)

//@function Calculates ADX Rating (ADXR) using current and historical ADX values
//@param period Number of bars used in ADX calculation
//@param rating_period Number of bars between current and historical ADX
//@returns tuple of ADXR value, ADX value, +DI, -DI
adxr(simple int period, simple int rating_period) =>
    if period <= 0
        runtime.error("Period must be greater than 0")
    if rating_period <= 0
        runtime.error("Rating period must be greater than 0")
    var float EPSILON = 1e-10
    float alpha = 1.0/float(period)
    float tr = na(close[1]) ? high - low : math.max(high - low, math.max(math.abs(high - close[1]), math.abs(low - close[1])))
    float plus_dm = na(high[1]) ? 0.0 : high - high[1] > low[1] - low and high - high[1] > 0 ? high - high[1] : 0.0
    float minus_dm = na(low[1]) ? 0.0 : low[1] - low > high - high[1] and low[1] - low > 0 ? low[1] - low : 0.0
    var float e = 1.0
    var float tr_raw = na
    tr_raw := na(tr_raw) ? tr : (tr_raw * (period - 1) + tr) / period
    float tr_smooth = e > EPSILON ? tr_raw / (1.0 - e) : tr_raw
    var float pdm_raw = na
    pdm_raw := na(pdm_raw) ? plus_dm : (pdm_raw * (period - 1) + plus_dm) / period
    float plus_dm_smooth = e > EPSILON ? pdm_raw / (1.0 - e) : pdm_raw
    var float mdm_raw = na
    mdm_raw := na(mdm_raw) ? minus_dm : (mdm_raw * (period - 1) + minus_dm) / period
    float minus_dm_smooth = e > EPSILON ? mdm_raw / (1.0 - e) : mdm_raw
    float plus_di = tr_smooth != 0.0 ? math.min(100 * plus_dm_smooth / tr_smooth, 50.0) : 0.0
    float minus_di = tr_smooth != 0.0 ? math.min(100 * minus_dm_smooth / tr_smooth, 50.0) : 0.0
    float dx = plus_di + minus_di != 0.0 ? 100 * math.abs(plus_di - minus_di) / (plus_di + minus_di) : 0.0
    var float adx_raw = na
    adx_raw := na(adx_raw) ? 0.0 : (adx_raw * (period - 1) + dx) / period
    float adx_value = e > EPSILON ? adx_raw / (1.0 - e) : adx_raw
    e *= (1 - alpha)
    float historical_adx = adx_value[math.min(rating_period, bar_index)]
    float adxr_value = (adx_value + nz(historical_adx,0)) / 2.0
    [adxr_value, adx_value, plus_di, minus_di]

// ---------- Main loop ----------

// Inputs
i_period = input.int(14, "ADX Period", minval=1, tooltip="Number of bars used in ADX calculation")
i_rating_period = input.int(14, "Rating Period", minval=1, tooltip="Number of bars between current and historical ADX")

// Calculate ADXR
[adxr_value, adx_value, plus_di, minus_di] = adxr(i_period, i_rating_period)

// Plot
plot(adxr_value, "ADXR", color=color.yellow, linewidth=2)
plot(adx_value, "ADX", color=color.yellow, linewidth=2)
plot(plus_di, "+DI", color=color.yellow, linewidth=2)
plot(minus_di, "-DI", color=color.yellow, linewidth=2)

Overview

Average Directional Movement Index Rating (ADXR) smooths true range and directional movement to produce plus DI, minus DI, the directional index, and ADX. ADXR averages the current ADX with the ADX from the rating period bars earlier. The ADX period controls smoothing length, and the rating period sets that lag. It draws ADXR, ADX, plus DI, and minus DI as lines. It does not generate entries, exits, or stop-loss levels.

Details

Published by

mihakralj on GitHub

Type

Indicator, Pine Script v6

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.

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
ADX Periodint14i_period
Rating Periodint14i_rating_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

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