Indicator · Pine Script v5 · On the chart

DMI ADX Signals with MACD Signals

by g-moe· code credited to goodgains

This indicator plots entry signals directly on the price chart by combining Directional Movement Index (DMI) and Moving Average Convergence Divergence (MACD) indicators.

View on GitHub

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code130
Settings11inputs
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

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

dmi-adx-signals-macd-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 with MACD Signals", overlay = true)

// @keywords: dmi-adx, macd-signals, di-plus-minus, adx, crossover-signals, buy-sell-markers, entry-level, take-profit, stop-loss, signal-bar-range, session-filter, time-constraint, dual-signals, histogram-filter, triangle-markers, trade-levels, alert-conditions, confirmed-signals, breakout-confirmation, overlay-signals

// 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')

_tp1 = input.float(0.625, title = 'TP 1')
_tp2 = input.float(1.00, title = 'TP 2')
_tp3 = input.float(1.625, title = 'TP 3')

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




// macd
_macd_fast = input.int(12, title = 'MACD Fast')
_macd_slow = input.int(26, title = 'MACD Slow')
_macd_signal = input.int(9, title = 'MACD Signal')

[macdLine, signalLine, macd_hist] = ta.macd(close, _macd_fast, _macd_slow, _macd_signal)

macd_buy1 = macd_hist > 0
macd_sell1 = macd_hist < 0

macd_buy2 = ta.crossover(macd_hist, 0)
macd_sell2 = ta.crossunder(macd_hist, 0)



// generate signals
buy_signal1cond = dmi_buy1 and macd_buy1 and _signal1 and is_time and barstate.isconfirmed
buy_signal2cond = dmi_buy2 and macd_buy2 and _signal2 and is_time and barstate.isconfirmed

sell_signal1cond = dmi_sell1 and macd_sell1 and _signal1 and is_time and barstate.isconfirmed
sell_signal2cond = dmi_sell2 and macd_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 with MACD Signals offers two distinct signal logic modes that trigger when DMI and MACD confirm each other and price breaks the prior bar's high or low. Traders can enable a custom session filter to restrict signal generation to specific trading hours. The indicator also calculates and projects dynamic entry price, stop loss, and three take-profit targets based on multiples of the signal bar's range.

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, Support & resistance, Sessions & time

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
Use Signal 1booltrue_signal1
Use Signal 2booltrue_signal2
Use Time Constraintbooltrue_time_constraint
Time Sessionsession0645-1700_time_sess
TP 1float0.625_tp1
TP 2float1.00_tp2
TP 3float1.625_tp3
DMI Lengthint14_dmi_length
MACD Fastint12_macd_fast
MACD Slowint26_macd_slow
MACD Signalint9_macd_signal
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

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

This indicator plots auto trade signals for E-mini S&P 500 futures on the price chart. It computes an EMA200 filter along with day ETH RTH session levels and percentage-based entry zones. Signals trigger CALL or PUT cases when price crosses defined thresholds

Indicator v6 TrendSupport & resistance
Updated 6 weeks ago · None stated GitHub repository of Auto Trade Futures ES
114 stars

This indicator calculates key support and resistance levels by analyzing the first and second momentum derivatives of a Double Exponential Moving Average (DEMA). When the second derivative (momentum of momentum) crosses zero, it identifies local turning points

Indicator v4 Support & resistanceOscillators & momentum
Updated 1 year ago · None stated GitHub repository of Support and Resistance Levels

Moon Dev Lunar Sniper

by moondevonyt
92 stars

Moon Dev Lunar Sniper is a multi-indicator overlay that scores confluence across fast and slow EMAs, RSI, MACD, DMI, and BB width to fire signals only when score meets the minimum threshold. It plots buy and sell signals on the price chart, highlights cosmic b

Indicator v6 TrendOscillators & momentum Repaints
Updated 8 weeks ago · Custom licence GitHub repository of Moon Dev Lunar Sniper

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