Indicator · Pine Script v5 · On the chart

DMI ADX Signals

by g-moe· code credited to goodgains

This indicator combines the Directional Movement Index (DMI) and the Stochastic oscillator to plot directional trade signals directly on the price chart.

View on GitHub

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code127
Settings8inputs
LicenceNone statedfile: MPL-2.0
Last update5 months ago27 May 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

127 lines of Pine Script v5 from Tradingview/dmi-adx-signals.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

dmi-adx-signals.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © goodgains


//@version=5
indicator("DMI ADX Signals", overlay = true)

// @keywords: dmi-crossover, adx-directional, stochastic-oscillator, buy-sell-arrows, dual-signal-modes, session-filter, chicago-time-window, di-plus-minus, k-d-crossover, signal-confirmation-bar, entry-price-tracking, take-profit-levels, overlay-signals, alert-messages, trend-strength-filter, intraday-entries, crossover-signals, crossunder-signals, combined-filters, trade-timing

// settings
_signal1 = input.bool(true, title = 'Use Signal 1')
_signal2 = input.bool(true, title = 'Use Signal 2')

_time_constraint = input.bool(true, title = 'Use Time Constraint')
_time_sess = input.session("0645-1700", title = 'Time Session')


is_time = time(timeframe.period, _time_sess, "America/Chicago") or not _time_constraint



// dmi
_dmi_length = input.int(14, title = 'DMI Length')
[di_plus, di_minus, adx] = ta.dmi(_dmi_length, _dmi_length)

dmi_buy1 = ta.crossover(di_plus, di_minus)
dmi_sell1 = ta.crossover(di_minus, di_plus)

dmi_buy2 = di_plus >= di_minus
dmi_sell2 = di_minus >= di_plus



// stoch
periodK = input.int(14, title="%K Length", minval=1)
smoothK = input.int(1, title="%K Smoothing", minval=1)
periodD = input.int(3, title="%D Smoothing", minval=1)

k = ta.sma(ta.stoch(close, high, low, periodK), smoothK)
d = ta.sma(k, periodD)

stoch_buy1 = k > d
stoch_sell1 = k < d

stoch_buy2 = ta.crossover(k, d)
stoch_sell2 = ta.crossunder(k, d)



// generate signals
buy_signal1cond = dmi_buy1 and stoch_buy1 and _signal1 and is_time and barstate.isconfirmed
buy_signal2cond = dmi_buy2 and stoch_buy2 and _signal2 and is_time and barstate.isconfirmed

sell_signal1cond = dmi_sell1 and stoch_sell1 and _signal1 and is_time and barstate.isconfirmed
sell_signal2cond = dmi_sell2 and stoch_sell2 and _signal2 and is_time and barstate.isconfirmed

buy_signal1 = buy_signal1cond[1] and high > high[1]
buy_signal2 = buy_signal2cond[1] and high > high[1]

sell_signal1 = sell_signal1cond[1] and low < low[1]
sell_signal2 = sell_signal2cond[1] and low < low[1]

plotshape(buy_signal2, "Buy Signal 2", style = shape.triangleup, location = location.belowbar,
 color = color.rgb(55, 129, 58), text = '', size = size.small)

plotshape(buy_signal1, "Buy Signal 1", style = shape.triangleup, location = location.belowbar,
 color = color.rgb(129, 202, 132), text = '', size = size.small)

plotshape(sell_signal2, "Sell Signal 2", style = shape.triangledown, location = location.abovebar,
 color = color.rgb(255, 50, 50), text = '', size = size.small)

plotshape(sell_signal1, "Sell Signal 1", style = shape.triangledown, location = location.abovebar,
 color = color.rgb(212, 159, 209), text = '', size = size.small)



// tp and stop lines
var float entry = na
var float signal_bar_range = na
var float tp1 = na
var float tp2 = na
var float tp3 = na

var float sl = na

entry := (buy_signal1 or buy_signal2) ? high[1] : (sell_signal1 or sell_signal2) ? low[1] : entry[1]
signal_bar_range := (buy_signal1 or sell_signal1 or buy_signal2 or sell_signal2) ? high[1] - low[1] : signal_bar_range[1]

// tp1 := (buy_signal1 or buy_signal2) ? entry + (signal_bar_range * _tp1) 
//  : (sell_signal1 or sell_signal2) ? entry - (signal_bar_range * _tp1)
//  : tp1[1]

// tp2 := (buy_signal1 or buy_signal2) ? entry + (signal_bar_range * _tp2) 
//  : (sell_signal1 or sell_signal2) ? entry - (signal_bar_range * _tp2)
//  : tp2[1]

// tp3 := (buy_signal1 or buy_signal2) ? entry + (signal_bar_range * _tp3) 
//  : (sell_signal1 or sell_signal2) ? entry - (signal_bar_range * _tp3)
//  : tp3[1] 

// sl := (buy_signal1 or buy_signal2) ? low[1]
//  : (sell_signal1 or sell_signal2) ? high[1]
//  : sl[1] 


// plot(entry, title = 'Entry', color = color.blue, style = plot.style_circles)
// plot(tp1, title = 'TP 1', color = color.green, style = plot.style_circles)
// plot(tp2, title = 'TP 2', color = color.green, style = plot.style_circles)
// plot(tp3, title = 'TP 3', color = color.green, style = plot.style_circles)
// plot(sl, title = 'SL', color = color.fuchsia, style = plot.style_circles)




// alerts
var bool is_alert = na
var string alert_str = na

is_alert := buy_signal1 or buy_signal2 or sell_signal1 or sell_signal2
alert_str := buy_signal1 ? "BUY SIGNAL 1"
 : buy_signal2 ? "BUY SIGNAL 2"
 : sell_signal1 ? "SELL SIGNAL 1"
 : sell_signal2 ? "SELL SIGNAL 2"
 : na

if is_alert
    alert(alert_str, alert.freq_once_per_bar_close)

Overview

DMI ADX Signals offers two distinct signal logic modes: one based on DI line crossovers confirmed by Stochastic levels, and another based on Stochastic crossovers during active DI trends. Both modes require a price breakout beyond the previous bar's high or low and can be restricted to an intraday trading session. Signals are displayed as colored triangle shapes.

Details

Published by

g-moe on GitHub

Code credit

goodgains, as written in the script's header

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Trend, Oscillators & momentum, Sessions & time

Markets

Any symbol

Timeframes

M15-H1, M1-M5

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
Use Signal 1booltrue_signal1
Use Signal 2booltrue_signal2
Use Time Constraintbooltrue_time_constraint
Time Sessionsession0645-1700_time_sess
DMI Lengthint14_dmi_length
%K Lengthint14periodK
%K Smoothingint1smoothK
%D Smoothingint3periodD
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

SPY 0DTE Scalper - 15min

by chris-c-thomas
14 stars

This intraday overlay establishes directional bias and high-conviction swing setups for SPY on the 15-minute timeframe. It computes a weighted confluence score combining an EMA ribbon, a 50 EMA anchor, session VWAP bands, RSI divergence, ADX, TTM Squeeze, cand

Indicator v6 TrendOscillators & momentum
Updated 6 months ago · MIT GitHub repository of SPY 0DTE Scalper - 15min
6 stars

The ORB + Fib + MACD Indicator combines Opening Range Breakout mechanics with Fibonacci retracement levels and MACD momentum filtering. It determines the high and low bounds of a user-defined initial session window, projects Fibonacci entry zones, and calculat

Indicator v5 Sessions & timeSupport & resistance
Updated 7 months ago · None stated GitHub repository of ORB + Fib + MACD Indicator

Gold Dominator Pro

by thanvish21
1 stars

Gold Dominator Pro is a multi-indicator overlay designed primarily for gold trading. It combines higher-timeframe exponential moving averages with momentum oscillators like RSI, MACD, and StochRSI, alongside volatility tools such as ATR, Bollinger Bands, and A

Indicator v5 TrendOscillators & momentum
Updated 2 months ago · None stated GitHub repository of Gold Dominator Pro

Jinni v1

by Hurairahengg
1 stars

Jinni v1 is a Pine Script indicator that plots buy and sell signals on the price chart. It calculates two EMAs, one on close with length 34 and another on input source with length 65, to detect uptrend and downtrend. Additional checks include candle direction,

Indicator v5 TrendOscillators & momentum
Updated 2 years ago · None stated GitHub repository of Jinni v1

MTF RSI Signals

by iyoshikawa
1 stars

This indicator plots multi-timeframe RSI signals on the price chart. It calculates a smoothed RSI using short and long periods with EMA smoothing, then applies a Stoch filter for direction changes. Signals trigger on crossovers and levels, combined with ADX tr

Indicator v5 Oscillators & momentumTrend Repaints
Updated 5 months ago · None stated GitHub repository of MTF RSI Signals
1 stars

This indicator plots three exponential moving averages and shades London and New York session hours on the price chart. It generates buy and sell signals when the fast EMA crosses the slow EMA in the direction of the 200 EMA trend filter. Entries require confi

Indicator v6 TrendOscillators & momentum
Updated 5 months ago · None stated GitHub repository of Señales Intradía EMA + MACD

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