Indicator · Pine Script v5 · Own pane

ADX+

by benso87

ADX+ is an enhanced Average Directional Index (ADX) indicator that measures trend strength in a separate pane.

View on GitHub

GitHub stars24on the repository
Pine versionv5runs as is
Lines of code81
Settings17inputs
LicenceMPL-2.0
Last update4 years ago5 Oct 2022

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

81 lines of Pine Script v5 from ADX Plus.pine, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

ADX Plus.pine
//@version=5
//
// Author: benso87
// benso87.com
//
//
indicator('ADX+', shorttitle='ADX+', precision=2, max_bars_back=500)

nocolor=color.new(color.white, transp=100)
////////////////////////////////////////////////////////////
// Inputs

// General
length = input.int(14, title='Length', minval=1, group='General')

// Style
colorType = input.string('Dynamic', title='Color Type', options=['Static', 'Dynamic', 'MA Dependent'], group='Style')
colorStatic = input.color(color.white, title='Static Color', group='Style')
levelLow = input.float(20, title='Low', inline='low', minval=0, maxval=100, group='Style')
colorLow = input.color(color.aqua, title='', inline='low', group='Style')
colorMid = input.color(color.yellow, title='Mid', inline='mid', group='Style')
levelHigh = input.float(50, title='High', inline='high', minval=0, maxval=100, group='Style')
colorHigh = input.color(color.red, title='', inline='high', group='Style')
colorAbove = input.color(#0bff00, title='Above MA', group='Style')
colorBelow = input.color(#ff0014, title='Below MA', group='Style')
lineWidth = input.int(3, title='Line Width', minval=1, maxval=4, group='Style')

// Moving Average
useMA = input.bool(false, title='Moving Average', group='Moving Average')
maType = input.string('EMA', title='MA Type', options=['EMA', 'SMA'], group='Moving Average')
maLength = input.int(100, title='MA Length', minval=1, group='Moving Average')
maColorDef = input.color(color.white, title='MA Color', group='Moving Average')
maFill = input.bool(false, title='MA Fill', group='Moving Average')

// Level Plots
plotLevels = input.bool(true, title='Show Level Lines', group='Level Plots')


///////////////////////////////////////////////////////////////////////////////
// Functions

// Moving average type
f_ma(source, length, type) =>
    switch type
        'SMA' => ta.sma(source, length)
        'EMA' => ta.ema(source, length)
        'RMA' => ta.rma(source, length)
        'WMA' => ta.wma(source, length)


////////////////////////////////////////////////////////////
// Calculations

up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
trur = ta.rma(ta.tr, length)
plus = fixnan(100 * ta.rma(plusDM, length) / trur)
minus = fixnan(100 * ta.rma(minusDM, length) / trur)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), length)

adxMA = f_ma(adx, maLength, maType)

colorDynamic = adx >= levelHigh ? colorHigh : adx >= levelLow and adx < levelHigh ? colorMid : colorLow
colorMADep = adx >= adxMA ? colorAbove : adx <= adxMA ? colorBelow : colorStatic
adxColor = colorType == 'Dynamic' ? colorDynamic : colorType == 'MA Dependent' ? colorMADep : colorStatic

maColor = maFill ? adxColor : maColorDef

////////////////////////////////////////////////////////////
// Plots

adxPlot = plot(adx, title='ADX', color=adxColor, linewidth=lineWidth)
adxMAPlot = plot(useMA ? adxMA : na, title='ADX MA', color=maColor, linewidth=1)

fill(adxPlot, adxMAPlot, color=maFill ? color.new(adxColor, transp=70) : na)

hline(plotLevels ? levelLow : na, title='Low Level', linestyle=hline.style_dashed, color=color.new(color.white, transp=50))
hline(plotLevels ? levelHigh : na, title='High Level', linestyle=hline.style_dashed, color=color.new(color.white, transp=50))

Overview

ADX+ calculates directional movement and true range to produce the standard ADX line, with optional smoothing via a moving average (EMA or SMA). The line color can dynamically adapt based on customized trend strength thresholds or relative position to its moving average. Users can also enable horizontal level lines and shaded fills between the ADX and its signal line.

Details

Published by

benso87 on GitHub

Type

Indicator, Pine Script v5

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
Lengthint14length
Color TypestringDynamiccolorType
Static Colorcolorcolor.whitecolorStatic
Lowfloat20levelLow
colorLowcolorcolor.aquacolorLow
Midcolorcolor.yellowcolorMid
Highfloat50levelHigh
colorHighcolorcolor.redcolorHigh
Above MAcolor#0bff00colorAbove
Below MAcolor#ff0014colorBelow
Line Widthint3lineWidth
Moving AverageboolfalseuseMA
Show all 17 settings
SettingTypeDefaultVariable
MA TypestringEMAmaType
MA Lengthint100maLength
MA Colorcolorcolor.whitemaColorDef
MA FillboolfalsemaFill
Show Level LinesbooltrueplotLevels
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